ERfPM?AppleApple_partition_map?PM@ disk imageApple_HFS @3noogPM`Apple_FreeH+8.10JrD`K1 D^9(O9 7 xFx%"InfoPlist.strings&" MainMenu.nib& classes.nib'uuK1K1c&info.nib(uuK1K1c6 & info.nib.orig)uuK1K1c3& objects.nib*uuK1K1c &&objects.nib.orig+uuK1K1c'& classes.nib(&info.nib)& info.nib.orig*& objects.nib+&objects.nib.orig," Msgbox.nib, .DS_Store-J=J=K1K1c@, classes.nib.uuK1K1c,info.nib/uuK1K1c&,keyedobjects.nib0uuK1K1c -, .DS_Store., classes.nib/,info.nib0,keyedobjects.nib1script2%x11vnc-0.9.8_i386-apple-darwin_8.11.18 server.txt< N p J | T 0  X, lB "InstantSupport77K1K1cBfInstantSupport Resources appIcon.icnsK,K,K1KD3c{(AppSettings.plistK,K,K1K1c; CocoaDialoguuK1K1c,,  English.lprojK,K,K1KD3cA Resources"uJzK1K1cAscript1K,K,K1K1cP%x11vnc-0.9.8_i386-apple-darwin_8.11.12~j~jK1K1cq"< appIcon.icnsAppSettings.plist d B  ~ f B  v T @dl8F|X*"InstantSupport"InstantSupport%vj^6 CocoaDialog English.lproj(InfoPlist.stringsK,K,K1KD3c MainMenu.nib 77K1K1cAInfoPlist.strings  MainMenu.nib& keyedobjects.nib!77K1K1cb! keyedobjects.nib" Resources" .DS_Store#J'J{K1K1c@0" Info.plist$uuK1K1cJ("InfoPlist.strings%uuK1K1c$" MainMenu.nib&uuK1K1cA" Msgbox.nib,uJ=K1K1cA#" .DS_Store$" Info.plistN(zZ0b6"InstantSupportK1D`K:HInstantSupport .DS_StoreK1K2K2KD3c@b.TrashesK1KD;KD;K1cB@*InstantSupport.appK,K,K1KD3cA server.txt8D\D\TEXTttxt^0HFS+ Private DataK1K1K1K1@PWWHFS+ Private Data.Trashes .DS_StoreInstantSupport.appContentsK,K,K1KD3cAContents Info.plistK,K,K1KD3c;eMacOSK,K,K1K1cA ResourcesK,K,K1KD3cA Info.plistMacOSplistMacOS d$\:xp {^[ ]*$} $item]} { continue } set query_aro($item) 1 } } proc in_debug_mode {} { global menu_var if {![info exists menu_var(debug_gui)]} { return 0 } return $menu_var(debug_gui) } # Menubar utilities: proc menus_state {state} { global menu_b foreach case [array names menu_b] { set menu_button $menu_b($case) if {![winfo exists $menu_button]} { continue } $menu_button configure -state $state } } proc menus_enable {} { global menus_disabled menus_state "normal" set menus_disabled 0 } proc menus_disable {} { global menus_disabled set menus_disabled 1 menus_state "disabled" } # Entry box utilities: proc entry_state {x state} { global entry_box entry_label entry_ok entry_help entry_skip entry_browse global old_labels if {$x == "all"} { if {!$old_labels} { $entry_label configure -state $state } $entry_box configure -state $state $entry_ok configure -state $state $entry_skip configure -state $state $entry_help configure -state $state $entry_browse configure -state $state } elseif {$x == "label"} { if {!$old_labels} { $entry_label configure -state $state } } elseif {$x == "box"} { $entry_box configure -state $state } elseif {$x == "ok"} { $entry_ok configure -state $state } elseif {$x == "skip"} { $entry_skip configure -state $state } elseif {$x == "help"} { $entry_help configure -state $state } elseif {$x == "browse"} { $entry_browse configure -state $state } } proc entry_enable {{x "all"}} { entry_state $x normal } proc entry_disable {{x "all"}} { entry_state $x disabled } proc entry_browse_button {{show 1}} { global entry_browse if {$show} { pack $entry_browse -side left } else { pack forget $entry_browse } } proc entry_focus {} { global entry_box focus $entry_box } proc entry_select {} { global entry_box $entry_box selection range 0 end } proc entry_get {} { global entry_box return [$entry_box get] } proc entry_insert {str} { global entry_box entry_delete $entry_box insert end $str $entry_box icursor end } proc entry_delete {} { global entry_box $entry_box delete 0 end } # Utilities for remote control and updating vars. proc push_new_value {item name new {query 1}} { global menu_var always_update remote_output query_output global query_result_list set debug [in_debug_mode] set getout 0 set print_getout 0; set do_query_all 0 set newnew "" if {$item == "disconnect"} { set newnew "N/A" set do_query_all 1 } elseif {$always_update} { set do_query_all 1 } if {$item == "remote-cmd"} { # kludge for arbitrary remote command: if {[regexp {^Q:} $new]} { # extra kludge for Q:var to mean -Q var regsub {^Q:} $new "" new set qonly 1 } else { set qonly 0 } # need to extract item from new: set qtmp $new regsub {:.*$} $qtmp "" qtmp if {$qonly} { set rargs [list "-Q" "$qtmp"] set print_getout 1 set qargs "" } else { set rargs [list "-R" "$new"] set qargs "" } set getout 1 } elseif {[value_is_string $item]} { # string var: set rargs [list "-R" "$name:$new"] set qargs [list "-Q" "$name"] } else { # boolean var: set rargs [list "-R" "$name"] set qargs [list "-Q" "$name"] } if {! $query && ! $always_update} { set getout 1 } elseif {$item == "noremote"} { set getout 1 } elseif {[is_action $item] && ![opt_match Q $item] && $rargs != ""} { set getout 1 } elseif {[regexp {^(sid|id)$} $item] && ![regexp {^0x} $new]} { set getout 1 } set remote_output "" set query_output "" if {!$debug} { if [regexp {passwd} $rargs] { append_text "x11vnc ..." } else { append_text "x11vnc $rargs ..." } } if {$getout} { set remote_output [run_remote_cmd $rargs] if {$print_getout} { append_text "\t$remote_output" } append_text "\n" return } if {$do_query_all} { set all [all_query_vars] set qargs [list "-Q" $all] global last_query_all_time set last_query_all_time [clock seconds] } set rqargs [concat $rargs $qargs] set query [run_remote_cmd $rqargs] set query_output $query set query_result_list "" if {$newnew != ""} { set new $newnew } if {![see_if_ok $query $item "$name:$new"]} { # failed if {[regexp {^a..=} $query]} { # but some result came back # synchronize everything with a 2nd call. set query_output [query_all 1] } else { # server may be dead if {$item != "ping" && $item != "attach"} { try_connect } } } else { # succeeded # synchronize this variable (or variables) # for a speedup used the list parsed by see_if_ok. update_menu_vars "USE_LIST" if {$do_query_all} { global all_settings set all_settings $query } } } proc set_kmbc_str {} { global vl_bk vl_bm vl_bb vl_bc vl_bf vr_bk vr_bm vr_bb vr_bc vr_bf set str "" if {$vl_bk} { append str "K" } if {$vl_bm} { append str "M" } if {$vl_bb} { append str "B" } if {$vl_bc} { append str "C" } if {$vl_bf} { append str "F" } if {$vr_bk || $vr_bm || $vr_bb || $vr_bc || $vr_bf} { append str "," } if {$vr_bk} { append str "K" } if {$vr_bm} { append str "M" } if {$vr_bb} { append str "B" } if {$vr_bc} { append str "C" } if {$vr_bf} { append str "F" } entry_insert $str } proc insert_input_window {} { global text_area cleanup_window global ffont menu_var global vl_bk vl_bm vl_bb vl_bc vl_bf vr_bk vr_bm vr_bb vr_bc vr_bf append_text "\nUse these checkboxes to set the input permissions, " append_text "or type in the \"KMBCF...\"\n" append_text "-input string manually. Then press \"OK\" or \"Cancel\".\n" append_text "(note: an empty setting means use the default behavior, " append_text "see viewonly)\n\n" set w "$text_area.wk_f" catch {destroy $w} frame $w -bd 1 -relief ridge -cursor {top_left_arrow} set fl $w.fl frame $fl set fr $w.fr frame $fr label $fl.l -font $ffont -text "Normal clients: " checkbutton $fl.bk -pady 1 -font $ffont -anchor w -variable vl_bk \ -pady 1 -command set_kmbc_str -text "Keystrokes" checkbutton $fl.bm -font $ffont -anchor w -variable vl_bm \ -pady 1 -command set_kmbc_str -text "Mouse-Motion" checkbutton $fl.bb -font $ffont -anchor w -variable vl_bb \ -pady 1 -command set_kmbc_str -text "Button-Click" checkbutton $fl.bc -font $ffont -anchor w -variable vl_bc \ -pady 1 -command set_kmbc_str -text "Clipboard-Input" checkbutton $fl.bf -font $ffont -anchor w -variable vl_bf \ -pady 1 -command set_kmbc_str -text "Files" label $fr.l -pady 1 -font $ffont -text "View-Only clients:" checkbutton $fr.bk -font $ffont -anchor w -variable vr_bk \ -pady 1 -command set_kmbc_str -text "Keystrokes" checkbutton $fr.bm -font $ffont -anchor w -variable vr_bm \ -pady 1 -command set_kmbc_str -text "Mouse-Motion" checkbutton $fr.bb -font $ffont -anchor w -variable vr_bb \ -pady 1 -command set_kmbc_str -text "Button-Click" checkbutton $fr.bc -font $ffont -anchor w -variable vr_bc \ -pady 1 -command set_kmbc_str -text "Clipboard-Input" checkbutton $fr.bf -font $ffont -anchor w -variable vr_bf \ -pady 1 -command set_kmbc_str -text "Files" if {[info exists menu_var(input)]} { set input_str $menu_var(input) } else { set input_str "" } if {[regexp {(.*),(.*)} $input_str match normal viewonly]} { ; } else { set normal $input_str set viewonly "" } set vl_bk 0 set vl_bm 0 set vl_bb 0 set vl_bc 0 set vl_bf 0 set vr_bk 0 set vr_bm 0 set vr_bb 0 set vr_bc 0 set vr_bf 0 if {[regexp -nocase {K} $normal]} { set vl_bk 1 } if {[regexp -nocase {M} $normal]} { set vl_bm 1 } if {[regexp -nocase {B} $normal]} { set vl_bb 1 } if {[regexp -nocase {C} $normal]} { set vl_bc 1 } if {[regexp -nocase {F} $normal]} { set vl_bf 1 } if {[regexp -nocase {K} $viewonly]} { set vr_bk 1 } if {[regexp -nocase {M} $viewonly]} { set vr_bm 1 } if {[regexp -nocase {B} $viewonly]} { set vr_bb 1 } if {[regexp -nocase {C} $viewonly]} { set vr_bc 1 } if {[regexp -nocase {F} $viewonly]} { set vr_bf 1 } pack $fl.l $fl.bk $fl.bm $fl.bb $fl.bc $fl.bf -side top -fill x pack $fr.l $fr.bk $fr.bm $fr.bb $fr.bc $fr.bf -side top -fill x pack $fl $fr -side left update update idletasks $text_area window create end -window $w $text_area see end $text_area insert end "\n" # $text_area insert end "\n\n\n\n\n\n\n\n\n" set cleanup_window $w } proc set_ca_str {w} { global ca_bk ca_bm ca_bb ca_bc ca_bf ca_di if {$ca_di} { entry_insert "disconnect" $w.bk configure -state disabled $w.bm configure -state disabled $w.bb configure -state disabled $w.bc configure -state disabled $w.bf configure -state disabled return } $w.bk configure -state normal $w.bm configure -state normal $w.bb configure -state normal $w.bc configure -state normal $w.bf configure -state normal set str "" if {$ca_bk} { append str "K" } if {$ca_bm} { append str "M" } if {$ca_bb} { append str "B" } if {$ca_bc} { append str "C" } if {$ca_bf} { append str "F" } entry_insert $str } proc insert_client_action_window {input} { global text_area cleanup_window global ffont menu_var global ca_bk ca_bm ca_bb ca_bc ca_bf ca_di append_text "\nUse these checkboxes to set the input permissions " append_text "for this client\n-OR- whether to disconnect it instead. " append_text "Then press \"OK\" or \"Cancel\".\n\n" set w "$text_area.ca_f" catch {destroy $w} frame $w -bd 1 -relief ridge -cursor {top_left_arrow} checkbutton $w.di -pady 1 -font $ffont -anchor w -variable ca_di \ -pady 1 -command "set_ca_str $w" -text "Disconnect " checkbutton $w.bk -font $ffont -anchor w -variable ca_bk \ -pady 1 -command "set_ca_str $w" -text "Keystrokes" checkbutton $w.bm -font $ffont -anchor w -variable ca_bm \ -pady 1 -command "set_ca_str $w" -text "Mouse-Motion" checkbutton $w.bb -font $ffont -anchor w -variable ca_bb \ -pady 1 -command "set_ca_str $w" -text "Button-Click" checkbutton $w.bc -font $ffont -anchor w -variable ca_bc \ -pady 1 -command "set_ca_str $w" -text "Clipboard" checkbutton $w.bf -font $ffont -anchor w -variable ca_bf \ -pady 1 -command "set_ca_str $w" -text "Files" set ca_di 0 set ca_bk 0 set ca_bm 0 set ca_bb 0 set ca_bf 0 set ca_bc 0 if {[regexp -nocase {K} $input]} { set ca_bk 1 } if {[regexp -nocase {M} $input]} { set ca_bm 1 } if {[regexp -nocase {B} $input]} { set ca_bb 1 } if {[regexp -nocase {C} $input]} { set ca_bc 1 } if {[regexp -nocase {F} $input]} { set ca_bf 1 } pack $w.di $w.bk $w.bm $w.bb $w.bc $w.bf -side left update update idletasks $text_area window create end -window $w $text_area see end $text_area insert end "\n" set cleanup_window $w } proc cleanup_text_window {} { global cleanup_window if {[info exists cleanup_window]} { catch {destroy $cleanup_window} } } # For updating a string variable. Also used for simple OK/Cancel dialogs # with entry = 0. proc entry_dialog {item {entry 1}} { global menu_var entry_str entry_set entry_dialog_item global unset_str connected_to_x11vnc entry_box set entry_str "Set $item" set entry_set 0 set entry_dialog_item $item entry_enable menus_disable if {$item == "passwd" || $item == "viewpasswd"} { $entry_box configure -show "*" } if {$entry} { entry_insert "" if {[info exists menu_var($item)] && $menu_var($item) != $unset_str} { entry_insert $menu_var($item) entry_select } if {[is_browse $item]} { entry_browse_button } set_info "Set parameter in entry box, " entry_focus } else { entry_disable box } set clean_text_window 0; if {$item == "input"} { insert_input_window set clean_text_window 1 } update # wait for user reply: vwait entry_set set rc $entry_set set entry_set 0 set value [entry_get] update entry_browse_button 0 set entry_str "Set... :" entry_delete entry_disable menus_enable if {$clean_text_window} { cleanup_text_window; } update if {! $entry} { ; } elseif {$rc} { set menu_var($item) $value } else { if {[in_debug_mode]} { append_text "skipped setting $item\n" } } $entry_box configure -show "" return $rc } proc warning_dialog {msg {item "gui"} } { append_text $msg # just reuse the entry widgets for a yes/no dialog return [entry_dialog $item 0] } # For updating a boolean toggle: proc check_var {item} { global menu_var set inval $menu_var($item); if {$item == "debug_gui"} { return ""; } set rname $item if {! $inval} { if {[regexp {^no} $item]} { regsub {^no} $rname "" rname } else { set rname "no$rname" } } return $rname } proc see_if_ok {query item expected} { global query_result_list set ok 0 set found "" set query_result_list [split_query $query] foreach q $query_result_list { # XXX following will crash if $item is not a good regexp # need to protect it \Q$item\E style... # if {[regexp "^$item:" $q]} { # set found $q # } if {[string first "$item:" $q] == 0} { set found $q } if {$q == $expected} { set ok 1 if {$found != ""} { break; } } } if {$found == ""} { set msg $query regsub {^a..=} $msg {} msg if {[string length $msg] > 60} { set msg [string range $msg 0 60] } } else { set msg $found } if {!$ok && $found != ""} { # check for floating point match: set v1 "" set v2 "" regexp {:([0-9.][0-9.]*)$} $found m0 v1 regexp {:([0-9.][0-9.]*)$} $expected m0 v2 if {$v1 != "" && $v2 != ""} { set diff "" catch {set diff [expr "$v1 - $v2"]} if {$diff != ""} { if {$diff < 0} { set diff [expr "0.0 - $diff"] } if {$diff < 0.00001} { set ok 1 } } } } if {$ok} { append_text "\tSet OK ($msg)\n" return 1 } elseif {[opt_match P $item] && [regexp {:(-|\+)} $expected]} { # e.g. blackout:+30x30+20+20 append_text "\t($msg)\n" return 1 } elseif {[regexp {:[0-9]\.[0-9]} $expected]} { append_text "\t($msg)\n" return 1 } elseif {$item == "connect" || $item == "disconnect" || $item == "client" || $item == "client_input"} { append_text "\t($msg)\n" return 1 } elseif {$item == "passwd" || $item == "viewpasswd"} { append_text "\t($msg)\n" return 1 } else { append_text "\t*FAILED* $msg\n" return 0 } } proc get_default_vars {} { global default_var set qry [all_query_vars] append qry ",vncconnect" set q "" set i 0 set all "" foreach s [split $qry ","] { if {$q != ""} { append q "," } append q $s incr i if {$i > 50} { set qargs [list "-QD" $q] set a [run_remote_cmd $qargs] if {$all != ""} { append all "," } append all $a set q "" set i 0 } } if {$q != ""} { set qargs [list "-QD" $q] set a [run_remote_cmd $qargs] if {$all != ""} { append all "," } append all $a } # old way, qry too long... # set qargs [list "-QD" $qry] # set all [run_remote_cmd $qargs] if {[regexp {ans=} $all]} { #append_text "Retrieved all default settings.\n" } else { #append_text "Failed to retrieve default settings.\n" } set query_result_list [split_query $all] set default_var(gui) "" foreach piece $query_result_list { if {[regexp {^([^:][^:]*):(.*)$} $piece m0 item val]} { if {$val == "N/A"} { if {$item == "vncconnect"} { set val 1 } else { set val "" } } if {$item == "display"} { set val "" } elseif {$item == "desktop"} { set val "" } elseif {$item == "auth"} { set val "" } elseif {$item == "gui"} { continue } # some hacks we do here for now.. if {$item == "cursor" && $val == ""} { set val "most" } elseif {$item == "scrollcopyrect" && $val == ""} { set val "always" } elseif {$item == "wirecopyrect" && $val == ""} { set val "always" # } elseif {$item == "overlay_nocursor" && $val == 0} { # set val 1 } set default_var($item) $val #puts "default: $item -> $val" } } } proc tilde_expand {file} { global env if {[file exists $file]} { return $file } set user "" if {[info exists env(USER)]} { set user $env(USER) } if {$user == "" && [info exists env(LOGNAME)]} { set user $env(LOGNAME) } set home "" if {[info exists env(HOME)]} { set home $env(HOME) } elseif {$user != ""} { set home "/home/$user" } if {[regexp {^~} $file]} { if {[regexp {^~/} $file]} { if {$home != ""} { regsub {^~} $file $home file } } else { regsub {^~} $file "/home/" file } } return $file } proc insert_cmdline_vars {} { global env cmd_var menu_var default_var x11vnc_cmdline if {![info exists x11vnc_cmdline]} { return } if {$x11vnc_cmdline == ""} { return } set cmd_var(novar) 1 set str [string trim $x11vnc_cmdline] while {[regexp -- {^-} $str]} { if {[regexp -- {^--*([^ \t][^ \t]*)(.*)$} $str m var rest]} { set rest [string trim $rest] set var [string trim $var] if {[regexp {^\{\{([^\}]*)\}\}(.*)} $rest m val rest]} { set str [string trim $rest] set cmd_var($var) $val } else { set str $rest set cmd_var($var) "boolean" } } else { break } } if {[info exists cmd_var(rc)]} { load_settings $cmd_var(rc) } elseif {[info exists cmd_var(norc)]} { ; } else { set filex [tilde_expand "~/.x11vncrc"] if {[file exists $filex]} { load_settings $filex } } foreach var [array names cmd_var] { if {$var == "novar"} { continue } if {[regexp {^[ \t]*$} $var]} { continue } if {[info exists menu_var($var)]} { if {$cmd_var($var) == "boolean"} { set menu_var($var) 1 } else { set menu_var($var) $cmd_var($var) } } } } proc copy_default_vars {} { global menu_var default_var foreach item [array names default_var] { if {[info exists menu_var($item)]} { if {[info exists default_var($item)]} { set menu_var($item) $default_var($item) } } } foreach item [array names menu_var] { if {[info exists default_var($item)]} { set menu_var($item) $default_var($item) } } } proc update_menu_vars {{query ""}} { global all_settings menu_var query_result_list set debug [in_debug_mode] if {$query == "USE_LIST"} { ; } elseif {$query == ""} { set query_result_list [split_query $all_settings] } else { set query_result_list [split_query $query] } foreach piece $query_result_list { #puts stderr "UMV: $piece" if {[regexp {^([^:][^:]*):(.*)$} $piece m0 item val]} { if {[info exists menu_var($item)]} { set old $menu_var($item) #puts stderr " $old" if {$val == "N/A"} { continue } set menu_var($item) $val } if {$item == "clients"} { update_clients_menu $val } elseif {$item == "display"} { set_x11_display $val } elseif {$item == "vncdisplay"} { set_vnc_display $val } elseif {$item == "http_url"} { set_vnc_url $val } } } } proc load_settings {{file ""}} { global menu_var default_var env if {$file == ""} { if {![info exists menu_var(load-settings)]} { return } set file $menu_var(load-settings) } if {$file == ""} { return } set fh "" set filex [tilde_expand $file] catch {set fh [open $filex "r"]} if {$fh == ""} { append_text "load_settings: *** failed to open $filex ***\n" return } copy_default_vars set str "" while {[gets $fh line] > -1} { regsub -all {\\#} $line {__QUOTED_HASH__} line if {[regexp {^[ \t]*#} $line]} { continue } for {set i 0} {$i < 5} {incr i} { regsub {#.*$} $line "" line } if {[regexp {^[ \t]*$} $line]} { continue } regsub -all {__QUOTED_HASH__} $line {#} line if {[regexp {\\$} $line]} { regsub {\\$} $line " " line append str "$line" } else { append str "$line\n" } } close $fh set count 0 set parms "" foreach line [split $str "\n"] { set line [string trim $line] regsub {^--*} $line "" line regsub -all {[ \t][ \t]*} $line " " line set list [split $line] set item [lindex $list 0] set value [lindex $list 1] if {[regexp {^[ \t]*$} $item]} { continue } if {$item == "gui"} { continue } if {[info exists menu_var($item)]} { if {[value_is_bool $item]} { set menu_var($item) 1 incr count append parms " -$item\n" } elseif {[value_is_string $item]} { if {$value != ""} { set menu_var($item) $value set nitem [get_nitem $item] append parms " -$nitem $value\n" incr count } } } } append_text "loaded $count parameter settings from $filex" if {$count > 0} { append_text ":\n" append_text $parms } else { append_text ".\n" } } proc save_settings {} { set rc_text [get_settings_rcfile] set top "# # This file is based on the current x11vnc settings and can be used as # as a ~/.x11vncrc defaults file. If saved to another filename, these # settings can be passed to x11vnc at startup via \"-rc \". # # The rc file comment character is \"#\". Use \"\\#\" for the literal char. # You can continue lines using \"\\\" as the last character of a line. # # Lines beginning with \"#d\" indicate the parameter value is at its default # setting and you probably want to leave it commented out. # # Lines beginning with \"#?\" indicate parameters you probably do not # want to hardwire to the current setting (uncomment if you want that). # # Some parameters are boolean, e.g. -forever, and take no value; while # the others, e.g. -wait 50, take a string or numerical value. # # For booleans, the line will end with comment \"default: on\" or # \"default: off\" indicating the default setting. (Note: often # \"-nofoobar\" corresponds to option \"-foobar\" and the former is # \"the default\", e.g. -norepeat). # # For string or numerical options, the value \"\" in a line below # means the default is unset and you will need to supply some non-empty # value to use the parameter. For reference, if the default differs # from your value it placed at the end of the line as a comment. # # Feel free to uncomment or comment any of the lines or to change any # of the values of the parameters. Don't be surprised that most if not # all of the lines below are commented out (x11vnc has so many parameters, # most of them will be at their default values). #------------------------------------------------------------------------- " set rc_text "$top$rc_text" global env save_settings_var save_settings_var_ok if {[info exists env(HOME)]} { set save_settings_var "$env(HOME)/.x11vncrc" } else { set save_settings_var ".x11vncrc" } set save_settings_var_ok 0 set w [textwin "save_settings" "Save Settings..." $rc_text \ "save_settings_var+Save as:"] tkwait window $w if {$save_settings_var_ok == 1} { set file $save_settings_var if {$file == ""} { return } set file [tilde_expand $file] append_text "\nSaving current settings to $file ...\n" if {[file exists $file]} { set backup "${file}~" append_text "Backing up $file -> $backup ...\n" catch {file delete -force $backup} set emsg "*** Backup to $backup failed. ***\n" if {![file exists $backup]} { catch {file copy -force $file $backup} if {![file exists $backup]} { append_text $emsg bell } } else { append_text $emsg bell } } set fh "" catch {set fh [open $file "w"]} if {$fh != ""} { puts $fh $rc_text close $fh if {![file exists $file]} { append_text "*** Saving to $file failed. ***\n" bell } else { append_text "Done.\n" } } else { append_text "*** Open of $file failed. ***\n" bell } } } proc clear_all {} { global menu_var unset_str set debug [in_debug_mode] foreach item [array names menu_var] { if {$item == "debug_gui"} { continue } if {[info exists menu_var($item)]} { if {[is_action $item]} { set menu_var($item) "" } elseif {[value_is_bool $item]} { set menu_var($item) 0 } elseif {[value_is_string $item]} { set menu_var($item) $unset_str } } } append_text "Cleared all settings.\n" } proc defaults_all {} { copy_default_vars append_text "Reset all variables to default values.\n" } proc all_query_vars {} { global query_ans_list query_aro_list all_settings global cache_all_query_vars if {$cache_all_query_vars != ""} { return $cache_all_query_vars } set qry "" foreach item $query_ans_list { if {$qry == ""} { set qry $item } else { append qry ",$item" } } foreach item $query_aro_list { if {$qry == ""} { set qry $item } else { append qry ",$item" } } set cache_all_query_vars $qry #puts $qry return $qry } proc query_all {{quiet 0}} { global query_ans_list query_aro_list all_settings global last_query_all_time dtime 1 set qry [all_query_vars] set qargs [list "-Q" $qry] set all [run_remote_cmd $qargs] if {[regexp {ans=} $all]} { if {! $quiet} { append_text "Retrieved all current settings.\n" } set all_settings $all update_menu_vars $all } else { if {! $quiet} { append_text "Failed to retrieve current settings.\n" } } set last_query_all_time [clock seconds] dtime 2 return $all } proc set_info {str} { global info_str info_label #set w1 [$info_label cget -width] #set w2 [winfo width $info_label] #puts "set_info: w=$w1 winfo=$w2" #append_text "$str\n" set info_str "$str" update } proc append_text {str} { global text_area text_area_str if {![info exists text_area_str]} { set text_area_str "" } append text_area_str $str if {![info exists text_area]} { puts stderr $str return } if {$text_area == ""} { puts stderr $str return } if {![winfo exists $text_area]} { puts stderr $str return } $text_area insert end $str $text_area see end } proc show_all_settings {} { global all_settings global client_sock client_tail global x11vnc_client_file set txt "\nRead-Write settings:\n\n" foreach item [split_query $all_settings] { regsub {:} $item {: } item append txt " $item\n" if {[regexp {noremote} $item]} { append txt "\nRead-Only settings:\n\n" } } append txt "\nInternal settings:\n\n" append txt "x11vnc_client_file: $x11vnc_client_file\n" if {[info exists client_tail]} { append txt "client_tail: $client_tail\n" } else { append txt "client_tail: unset\n" } if {[info exists client_sock]} { append txt "client_sock: $client_sock\n" } else { append txt "client_sock: unset\n" } set estr "" catch {set estr [exec env | grep -i X11VNC]} append txt "$estr\n" textwin "Settings" "All Current Settings" $txt } proc show_logfile {} { global menu_var unset_str set logfile [tilde_expand $menu_var(logfile)] if {$logfile == "" || $logfile == $unset_str} { set txt "\nNo logfile was specified at x11vnc startup.\n\n" } elseif {![file exists $logfile]} { set txt "\nLogfile \"$logfile\" does not exist.\n\n" } else { set fh "-3" set err "" catch {set fh [open $logfile "r"]} err if {$fh == "-3"} { set txt "\nError opening \"$logfile\" $err.\n\n" } else { set txt "\nLogfile \"$logfile\" current contents:\n" while {[gets $fh line] > -1} { append txt "$line\n" } close $fh } } textwin "Logfile" "Logfile" $txt } proc tail_logfile {} { global menu_var unset_str ffont set logfile $menu_var(logfile) set txt "" if {$logfile == "" || $logfile == $unset_str} { set txt "\nNo logfile was specified at x11vnc startup.\n\n" } elseif {![file exists $logfile]} { set txt "\nLogfile \"$logfile\" does not exist.\n\n" } else { set cmd "" set xterm_cmd "xterm -sb -fn $ffont -geometry 80x45 -title x11vnc-logfile -e" set cmd [split $xterm_cmd] lappend cmd "tail" lappend cmd "-3000f" lappend cmd $logfile lappend cmd "&" catch {[eval exec $cmd]} } if {$txt != ""} { textwin "Logfile" "Logfile" $txt } } proc set_connected {yesno} { global connected_to_x11vnc set orig $connected_to_x11vnc if {$yesno == "yes"} { set connected_to_x11vnc 1 } else { set connected_to_x11vnc 0 no_x11_display no_vnc_display } if {$orig != $connected_to_x11vnc} { set_widgets } } proc detach_from_display {} { global connected_to_x11vnc reply_xdisplay x11vnc_xdisplay set str "Detaching from X display." if {$reply_xdisplay != ""} { set str "Detaching from $reply_xdisplay." } elseif {$x11vnc_xdisplay != ""} { set str "Detaching from $x11vnc_xdisplay." } if {$connected_to_x11vnc} { append_text "$str\n" } set_connected no } proc do_stop_quit {} { push_new_value "stop" "stop" 1 0 set_connected no update after 250 destroy . } # Menu item is an action: proc do_action {item} { global menu_var connected_to_x11vnc beginner_mode if {[in_debug_mode]} { append_text "action: \"$item\"\n" } #puts "action: \"$item\"\n" if {$item == "ping"} { if {$beginner_mode} { try_connect_and_query_all } else { try_connect } return } elseif {$item == "start"} { start_x11vnc return } elseif {$item == "detach"} { detach_from_display return } elseif {$item == "attach"} { try_connect_and_query_all return } elseif {$item == "update-all"} { query_all return } elseif {$item == "clear-all"} { clear_all return } elseif {$item == "defaults-all"} { defaults_all return } elseif {$item == "save-settings"} { save_settings return } elseif {$item == "show-start-cmd"} { show_start_cmd return } elseif {$item == "all-settings"} { show_all_settings return } elseif {$item == "show-logfile"} { show_logfile return } elseif {$item == "tail-logfile"} { tail_logfile return } elseif {$item == "Misc-Tuning:"} { menu_help "$item" return } elseif {$item == "WindowView"} { change_view_state return } elseif {$item == "quit" || $item == "Quit"} { destroy . exit 0 } elseif {$item == "stop+quit"} { do_stop_quit } if {[value_is_string $item]} { if {! [entry_dialog $item]} { return } set new $menu_var($item) set name $item } else { set new 1 set name $item } if {$item == "load-settings"} { load_settings return } if {! $connected_to_x11vnc} { ; } elseif {[regexp {^(stop|quit|exit|shutdown)$} $item]} { # just do -R append_text "stopping remote x11vnc server...\n" push_new_value $item $name $new 0 set_connected no } elseif {[opt_match Q $item]} { push_new_value $item $name $new 1 } else { push_new_value $item $name $new 0 } } proc ptime {time} { set usec [lindex [split $time] 0] set sec [format "%.3f" [expr "$usec / 1000000.0"]] puts "time: $sec secs." } proc do_var {item} { global connected_to_x11vnc item_cascade menu_var set debug [in_debug_mode] set string 0 if {[is_action $item] || $item == "WindowView"} { # Menu item is action: if {$debug} { ptime [time {do_action $item}] } else { do_action $item } return } if {[value_is_string $item]} { # Menu item is a string: if {$item_cascade($item) != ""} { # Cascade sets variable automatically } else { # Otherwise Entry box if {![entry_dialog $item]} { return } } set new $menu_var($item) set name $item } else { # Menu item is a boolean: set name [check_var $item] if {$name == ""} { return } set new 1 } if {$connected_to_x11vnc} { if {$debug} { ptime [time {push_new_value $item $name $new 1}] } else { push_new_value $item $name $new 1 } if {$item == "http"} { global vnc_url append_text " URL: $vnc_url\n" } } } proc menu_help {item} { if ![help_win $item] { textwin "nohelp" "No help available" \ "Sorry, no help avaiable for \"$item\"" } } proc opt_match {c item} { global item_opts if {[info exists item_opts($item)]} { if {[regexp "^\[A-z\]*$c" $item_opts($item)]} { return 1 } } return 0 } proc is_action {item} { return [opt_match A $item] } proc is_gui_internal {item} { if {$item == "Properties"} { return 1 } if {$item == "Tray"} { return 1 } return [opt_match G $item] } proc is_browse {item} { return [opt_match F $item] } proc value_is_string {item} { global item_bool if {![info exists item_bool($item)]} { return 0 } if {! $item_bool($item)} { return 1 } else { return 0 } } proc value_is_bool {item} { global item_bool if {![info exists item_bool($item)]} { return 0 } if {$item_bool($item)} { return 1 } else { return 0 } } proc split_query0 {query} { # original slower way with regexp/regsub regsub -all {aro=} $query {ans=} query set items {} while {1} { if {! [regexp {^ans=(.*)$} $query m0 m1]} { break } set item $m1 set m2 "" regexp {,ans=.*$} $item m2 regsub {,ans=.*$} $item "" item if {$item != ""} { lappend items $item } set query $m2 regsub {^,} $query "" query } return $items } proc split_query {query} { regsub -all {aro=} $query {ans=} query set items {} while {1} { set n [string first "ans=" $query] if {$n < 0} { break } set from [expr $n+4] set m [string first ",ans=" $query] if {$m < 0} { set more 0 set item [string range $query $from end] } else { set more 1 set to [expr $m-1] set item [string range $query $from $to] } if {$item != ""} { lappend items $item } if {$more} { incr m set query [string range $query $m end] } else { set query "" } } return $items } proc set_x11_display {name} { global x11_display set x11_display "x11vnc X display: $name" set_name "tkx11vnc - $name" } proc set_vnc_display {name} { global vnc_display icon_mode set vnc_display "VNC display: $name" if {$icon_mode} { set_icon_label } } proc set_vnc_url {name} { global vnc_url set vnc_url $name } proc no_x11_display {} { set_x11_display "(*none*)" set_name "tkx11vnc" } proc no_vnc_display {} { set_vnc_display "(*none*)" } proc no_vnc_url {} { set_vnc_url "(*none*)" } proc get_vnc_display_number {} { global vnc_display if ![info exists vnc_display] { return "none" } if {$vnc_display == ""} { return "none" } set str $vnc_display regsub {VNC display: *} $str "" str if [regexp {:([0-9][0-9]*)} $str m0 n] { return $n } return "none" } proc fetch_displays {} { set qargs [list "-Q" "display,vncdisplay"] set result [run_remote_cmd $qargs] set got_x11 0 set got_vnc 0 set got_url 0 foreach item [split_query $result] { if {[regexp {^display:(.*)$} $item m0 m1]} { set_x11_display $m1 set got_x11 1 } elseif {[regexp {^vncdisplay:(.*)$} $item m0 m1]} { set_vnc_display $m1 set got_vnc 1 } elseif {[regexp {^http_url:(.*)$} $item m0 m1]} { set_vnc_url $m1 set got_url 1 } } if {! $got_x11} { no_x11_display } if {! $got_vnc} { no_vnc_display } if {! $got_url} { no_vnc_url } } proc client_dialog {client} { set cid "" set host "" set ip "" global menu_var text_area cleanup_window item_bool #::::::::