[Tkabber-dev] r1756 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Mar 28 21:06:43 MSK 2009


Author: sergei
Date: 2009-03-28 21:06:43 +0300 (Sat, 28 Mar 2009)
New Revision: 1756

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/proxy.tcl
Log:
	* proxy.tcl: Removed proxy type 'none' to make sure that every proxy
	  entry represent a real proxy, which is better to understand.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-03-28 06:49:27 UTC (rev 1755)
+++ trunk/tkabber/ChangeLog	2009-03-28 18:06:43 UTC (rev 1756)
@@ -6,6 +6,9 @@
 	  not always works, so it should be switched on only if user knows how
 	  to work with it.
 
+	* proxy.tcl: Removed proxy type 'none' to make sure that every proxy
+	  entry represent a real proxy, which is better to understand.
+
 2009-03-27  Sergei Golovan  <sgolovan at nes.ru>
 
 	* custom.tcl: Run commands associated with customizable variables on

Modified: trunk/tkabber/proxy.tcl
===================================================================
--- trunk/tkabber/proxy.tcl	2009-03-28 06:49:27 UTC (rev 1755)
+++ trunk/tkabber/proxy.tcl	2009-03-28 18:06:43 UTC (rev 1756)
@@ -11,18 +11,18 @@
     foreach varname [lsort -dictionary [info vars ::proxy*]] {
 	upvar #0 $varname p
 	if {![info exists p(type)] || \
-		[lsearch -exact {none http https socks4 socks5} $p(type)] < 0} {
+		[lsearch -exact {http https socks4 socks5} $p(type)] < 0} {
 	    continue
 	}
 	set proxy [list type $p(type)]
 	if {[info exists p(host)]} {
 	    lappend proxy host $p(host)
-	} elseif {$p(type) != "none"} {
+	} else {
 	    continue
 	}
 	if {[info exists p(port)]} {
 	    lappend proxy port $p(port)
-	} elseif {$p(type) != "none"} {
+	} else {
 	    continue
 	}
 	if {[info exists p(username)]} {
@@ -38,10 +38,6 @@
 	    lappend proxy exclude $p(exclude)
 	}
 	switch -- $p(type) {
-	    none {
-		lappend tproxies $proxy
-		lappend hproxies $proxy
-	    }
 	    http {
 		lappend hproxies $proxy
 	    }
@@ -57,9 +53,7 @@
 	variable proxylist [list tunnels $tproxies http $hproxies]
     }
 
-    custom::defvar proxylist \
-	{tunnels {{type none match "localhost* 127.0.0.* 192.168.* 10.*"}}\
-	 http {{type none match "localhost* 127.0.0.* 192.168.* 10.*"}}} \
+    custom::defvar proxylist {tunnels {} http {}} \
 	[::msgcat::mc "Serialized array of proxy servers to connect via."] \
 	-type string -group Hidden
 
@@ -179,8 +173,12 @@
     variable proxylist
 
     switch -- $type {
-	tunnels -
-	http {}
+	tunnels {
+	    set add_type https
+	}
+	http {
+	    set add_type http
+	}
 	default {
 	    return -code error
 	}
@@ -189,7 +187,7 @@
     array set Proxy $proxylist
 
     set tools [frame $frame.tools]
-    pack $tools -side bottom -fill x -padx 1m
+    pack $tools -side bottom -fill x
     
     set sw [ScrolledWindow $frame.sw -scrollbar vertical]
     set sf [ScrollableFrame $frame.fields -constrainedwidth yes]
@@ -201,8 +199,10 @@
 
     set add [button $tools.add \
 		    -text [::msgcat::mc "Add proxy"] \
-		    -command [namespace code [list add_proxy $f $type none "" "" "" "" * ""]]]
-    pack $add -side right -padx 1m
+		    -command [namespace code \
+			[list add_proxy $f $type $add_type "" "" "" "" * \
+			      "localhost* 127.0.0.* 172.* 192.168.* 10.*"]]]
+    pack $add -side right -pady 2m
 
     set data($type,counter) 0
 
@@ -249,7 +249,7 @@
 	for {set i 1} {$i <= $data($type,counter)} {incr i} {
 	    if {$data($type,type,$i) == "remove"} continue
 
-	    if {[lsearch {none http https socks4 socks5} $data($type,type,$i)] < 0} {
+	    if {[lsearch {http https socks4 socks5} $data($type,type,$i)] < 0} {
 		continue
 	    }
 
@@ -271,6 +271,18 @@
 proc proxy::add_proxy {f type ptype host port username password match exclude} {
     variable data
 
+    switch -- $type {
+	tunnels {
+	    if {[lsearch -exact {remove https socks4 socks5} $ptype] < 0} return
+	}
+	http {
+	    if {[lsearch -exact {remove http} $ptype] < 0} return
+	}
+	default {
+	    return
+	}
+    }
+
     set i [incr data($type,counter)]
 
     set data($type,type,$i) $ptype
@@ -295,30 +307,20 @@
 
     set col 0
 
-    radiobutton $ff.proxy$i.none -text [::msgcat::mc "None"] \
-		-variable [namespace current]::data($type,type,$i) -value none \
-		-command [list [namespace current]::update_proxy $f $type $i]
-    grid $ff.proxy$i.none -row 0 -column [incr col] -sticky w
-
     if {$type == "tunnels"} {
 	radiobutton $ff.proxy$i.https -text [::msgcat::mc "HTTPS"] \
-		    -variable [namespace current]::data($type,type,$i) -value https \
-		    -command [list [namespace current]::update_proxy $f $type $i]
+		    -variable [namespace current]::data($type,type,$i) -value https
 	grid $ff.proxy$i.https -row 0 -column [incr col] -sticky w
 
 	radiobutton $ff.proxy$i.socks4 -text [::msgcat::mc "SOCKS4a"] \
-		    -variable [namespace current]::data($type,type,$i) -value socks4 \
-		    -command [list [namespace current]::update_proxy $f $type $i]
+		    -variable [namespace current]::data($type,type,$i) -value socks4
 	grid $ff.proxy$i.socks4 -row 0 -column [incr col] -sticky w
 
 	radiobutton $ff.proxy$i.socks5 -text [::msgcat::mc "SOCKS5"] \
-		    -variable [namespace current]::data($type,type,$i) -value socks5 \
-		    -command [list [namespace current]::update_proxy $f $type $i]
+		    -variable [namespace current]::data($type,type,$i) -value socks5
 	grid $ff.proxy$i.socks5 -row 0 -column [incr col] -sticky w
     } else {
-	radiobutton $ff.proxy$i.https -text [::msgcat::mc "HTTP"] \
-		    -variable [namespace current]::data($type,type,$i) -value http \
-		    -command [list [namespace current]::update_proxy $f $type $i]
+	label $ff.proxy$i.https -text [::msgcat::mc "HTTP"]
 	grid $ff.proxy$i.https -row 0 -column [incr col] -sticky w
     }
 
@@ -384,10 +386,6 @@
     grid columnconfigure $f 0 -weight 1
 }
 
-proc proxy::update_proxy {f type i} {
-    # TODO
-}
-
 proc proxy::remove_proxy {f type i} {
     variable data
 
@@ -476,17 +474,19 @@
 	array unset Args
 	array set Args $proxy
 
-	if {$Args(type) != "none"} {
-	    if {![info exists Args(host)] || [string length $Args(host)] == 0} {
-		continue
-	    }
+	if {[lsearch -exact {http https socks4 socks5} $Args(type)] < 0} {
+	    continue
+	}
 
-	    if {![info exists Args(port)] || ![string is integer -strict $Args(port)] || \
-		    $Args(port) < 0 || $Args(port) >= 65536} {
-		continue
-	    }
+	if {![info exists Args(host)] || [string length $Args(host)] == 0} {
+	    continue
 	}
 
+	if {![info exists Args(port)] || ![string is integer -strict $Args(port)] || \
+	        $Args(port) < 0 || $Args(port) >= 65536} {
+	    continue
+	}
+
 	set m 0
 	if {[info exists Args(match)]} {
 	    foreach pattern [split $Args(match)] {
@@ -508,10 +508,6 @@
 	}
 
 	if {$m && !$x} {
-	    if {$Args(type) == "none"} {
-		return {}
-	    }
-
 	    if {$port < 0} {
 		set res [list $Args(host) $Args(port)]
 	    } else {



More information about the Tkabber-dev mailing list