[Tkabber-dev] r1022 - in trunk/tkabber: . ifacetk trans

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Mar 6 20:45:43 MSK 2007


Author: sergei
Date: 2007-03-06 20:45:41 +0300 (Tue, 06 Mar 2007)
New Revision: 1022

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/privacy.tcl
   trunk/tkabber/trans/de.msg
Log:
	* trans/de.msg: Updated German translation (thanks to
	  Roger Sondermann).

	* ifacetk/iface.tcl: Moved "Activate privacy lists at startup" higher
	  in the menu item list.

	* privacy.tcl: Fixed bug with adding items to conference list, made
	  all privacy lists updated in one transaction without packets in
	  between. This makes changes in privacy lists taking significantly
	  more time. Fixed Tkabber behavior in case if server doesn't support
	  privacy lists (closes
	  http://yo.jabber.ru/bugzilla/show_bug.cgi?id=333).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-03-06 17:14:10 UTC (rev 1021)
+++ trunk/tkabber/ChangeLog	2007-03-06 17:45:41 UTC (rev 1022)
@@ -3,9 +3,19 @@
 	* chats.tcl: Fixed moving interface tabs by keyboard shortcuts
 	  <Control-Meta-Prior> and <Control-Meta-Next>.
 
-	* msgs/de.msg: Updated German translation (thanks to Roger
-	  Sondermann).
+	* msgs/de.msg, trans/de.msg: Updated German translation (thanks to
+	  Roger Sondermann).
 
+	* ifacetk/iface.tcl: Moved "Activate privacy lists at startup" higher
+	  in the menu item list.
+
+	* privacy.tcl: Fixed bug with adding items to conference list, made
+	  all privacy lists updated in one transaction without packets in
+	  between. This makes changes in privacy lists taking significantly
+	  more time. Fixed Tkabber behavior in case if server doesn't support
+	  privacy lists (closes
+	  http://yo.jabber.ru/bugzilla/show_bug.cgi?id=333).
+
 2007-03-04  Sergei Golovan  <sgolovan at nes.ru>
 
 	* msgs/de.msg: Updated German translation (thanks to Roger

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2007-03-06 17:14:10 UTC (rev 1021)
+++ trunk/tkabber/ifacetk/iface.tcl	2007-03-06 17:45:41 UTC (rev 1022)
@@ -260,6 +260,8 @@
 			    }}] \
 		  [list cascad [::msgcat::mc "Privacy rules"] {} privacy $ifacetk::options(show_tearoffs) \
 		       [list \
+			    [list checkbutton [::msgcat::mc "Activate lists at startup"] {} {} {} \
+				 -variable privacy::options(activate_at_startup)] \
 			    [list command [string trim [::msgcat::mc "Edit invisible list "]] {} {} {} \
 				 -command {privacy::edit_special_list invisible}] \
 			    [list command [string trim [::msgcat::mc "Edit ignore list "]] {} {} {} \
@@ -269,8 +271,6 @@
 			    [list checkbutton [::msgcat::mc "Accept messages from roster users only"] {} {} {} \
 				 -variable privacy::accept_from_roster_only \
 				 -command privacy::on_accept_from_roster_only_change] \
-			    [list checkbutton [::msgcat::mc "Activate lists at startup"] {} {} {} \
-				 -variable privacy::options(activate_at_startup)] \
 			    {separator} \
 			    [list command [::msgcat::mc "Manually edit rules"] {} {} {} \
 				 -command {privacy::request_lists}]]] \

Modified: trunk/tkabber/privacy.tcl
===================================================================
--- trunk/tkabber/privacy.tcl	2007-03-06 17:14:10 UTC (rev 1021)
+++ trunk/tkabber/privacy.tcl	2007-03-06 17:45:41 UTC (rev 1022)
@@ -13,10 +13,11 @@
 	      conference [::msgcat::mc "Requesting converence list: %s"]]
 
     array set send_messages \
-	[list ignore     [::msgcat::mc "Sending ignore list: %s"] \
-	      invisible  [::msgcat::mc "Sending invisible list: %s"] \
-	      visible    [::msgcat::mc "Sending visible list: %s"] \
-	      conference [::msgcat::mc "Sending conference list: %s"]]
+	[list ignore       [::msgcat::mc "Sending ignore list: %s"] \
+	      invisible    [::msgcat::mc "Sending invisible list: %s"] \
+	      visible      [::msgcat::mc "Sending visible list: %s"] \
+	      conference   [::msgcat::mc "Sending conference list: %s"] \
+	      subscription [::msgcat::mc "Changing accept messages from roster only: %s"]]
 
     array set edit_messages \
 	[list ignore     [::msgcat::mc "Edit ignore list"] \
@@ -27,8 +28,7 @@
     array set menu_messages \
 	[list ignore     [::msgcat::mc "Ignore list"] \
 	      invisible  [::msgcat::mc "Invisible list"] \
-	      visible    [::msgcat::mc "Visible list"] \
-	      conference [::msgcat::mc "Conference list"]]
+	      visible    [::msgcat::mc "Visible list"]]
 
     variable accept_from_roster 0
 
@@ -76,7 +76,7 @@
 proc privacy::open_dialog {connid res child} {
     if {![cequal $res OK]} {
 	MessageDlg .privacy_err -aspect 50000 -icon error \
-	    -message [format [::msgcat::mc "Requesting privacy rules: %s"] \
+	    -message [::msgcat::mc "Requesting privacy rules: %s" \
 			  [error_to_string $child]] \
 	    -type user -buttons ok -default 0 -cancel 0
 	return
@@ -274,7 +274,7 @@
 proc privacy::edit_list_dialog {connid ln name res child} {
     if {![cequal $res OK]} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
-	    -message [format [::msgcat::mc "Requesting privacy list: %s"] \
+	    -message [::msgcat::mc "Requesting privacy list: %s" \
 			  [error_to_string $child]] \
 	    -type user -buttons ok -default 0 -cancel 0
 	set child [jlib::wrapper:createtag query \
@@ -816,6 +816,7 @@
 
 
 proc privacy::edit_special_list_enddialog {connid w name} {
+    $w itemconfigure 0 -state disabled
     send_special_list $connid $name [$w.fields get 0 end]
     destroy $w
 }
@@ -823,7 +824,12 @@
 proc privacy::send_special_list {connid name items} {
     variable special_list
     variable cboxes
+    variable supported
 
+    if {![info exists supported($connid)] || !$supported($connid)} {
+	return
+    }
+
     if {![info exists special_list($connid,$name)]} {
 	set special_list($connid,$name) {}
     }
@@ -885,16 +891,26 @@
     }
 
     send_list_iq "$name-list" $items1 \
-	-command [list [namespace current]::update_tkabber_lists \
-		       $connid $name $items $postitems] \
+	-command [list [namespace current]::get_answer $connid]\
 	-connection $connid
+
+    # We have to vwait because all privacy lists should be updated
+    # before sending next stanzas
+    lassign [wait_for_answer $connid] res child
+
+    update_tkabber_lists $connid $name $items $postitems $res $child
 }
 
 # subscription-list is responsible for blocking all messages
 # not from the roster.
 proc privacy::send_subscription_list {connid} {
     variable accept_from_roster_only
+    variable supported
 
+    if {![info exists supported($connid)] || !$supported($connid)} {
+	return
+    }
+
     if {$accept_from_roster_only} {
 	set items [list [jlib::wrapper:createtag item \
 			     -vars [list type subscription \
@@ -908,9 +924,14 @@
     # If items aren't empty, we'll never send unavailable presence to
     # all users to whom directed presence was sent. Bug?
     send_list_iq "subscription-list" $items \
-	-command [list [namespace current]::update_tkabber_lists \
-		       $connid subscription $items {}] \
+	-command [list [namespace current]::get_answer $connid] \
 	-connection $connid
+
+    # We have to vwait because all privacy lists should be updated
+    # before sending next stanzas
+    lassign [wait_for_answer $connid] res child
+
+    update_tkabber_lists $connid subscription $items {} $res $child
 }
 
 proc privacy::on_accept_from_roster_only_change {args} {
@@ -932,14 +953,21 @@
     variable special_list
     variable cboxes
 
-    # Workaround for servers without privacy list support/push
-    if {$res == "OK"} {
-	set special_list($connid,$name) $items
+    switch -- $name {
+	subscription {
+	    # Subscription list doesn't contain JIDs
+	}
+	default {
+	    # Workaround for servers without privacy list support/push
+	    if {$res == "OK"} {
+		set special_list($connid,$name) $items
+	    }
+	    array unset cboxes $connid,$name,*
+	    foreach jid $special_list($connid,$name) {
+		set cboxes($connid,$name,$jid) 1
+	    }
+	}
     }
-    array unset cboxes $connid,$name,*
-    foreach jid $special_list($connid,$name) {
-	set cboxes($connid,$name,$jid) 1
-    }
 
     if {$res != "OK"} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
@@ -952,6 +980,7 @@
 	ignore -
 	conference -
 	subscription {
+	    # Some inefficiency here. We load three lists twice.
 	    join_lists $connid "i-am-visible-list" \
 		       {ignore-list invisible-list conference-list subscription-list} \
 		       {allow {} {}}
@@ -1000,7 +1029,6 @@
 
     # Appending myself to the list to make sure we can communicate
     # between own resources
-
     lappend items [jlib::wrapper:createtag item \
 		       -vars [list type jid \
 				   value [jlib::connection_bare_jid $connid] \
@@ -1014,10 +1042,12 @@
 		 -vars [list xmlns $::NS(privacy)] \
 		 -subtags [list [jlib::wrapper:createtag list \
 				     -vars [list name $ln]]]] \
-	    -command [list [namespace current]::get_items] \
+	    -command [list [namespace current]::get_items $connid] \
 	    -connection $connid
-	vwait [namespace current]::litems
-	foreach item $litems {
+
+	vwait [namespace current]::litems($connid)
+
+	foreach item $litems($connid) {
 	    jlib::wrapper:splitxml $item tag vars isempty chdata children
 	    catch { array unset tmp }
 	    array set tmp $vars
@@ -1028,6 +1058,7 @@
 	    incr i
 	}
     }
+    unset litems($connid)
 
     foreach {action vars subtags} $fallbacks {
 	lappend items [jlib::wrapper:createtag item \
@@ -1039,11 +1070,11 @@
 }
 
 
-proc privacy::get_items {res child} {
+proc privacy::get_items {connid res child} {
     variable litems
 
     if {$res != "OK"} {
-	set litems {}
+	set litems($connid) {}
 	return
     }
 
@@ -1051,9 +1082,9 @@
     jlib::wrapper:splitxml [lindex $children 0] tag vars isempty chdata children
 
     if {$tag == "list"} {
-	set litems $children
+	set litems($connid) $children
     } else {
-	set litems {}
+	set litems($connid) {}
     }
 }
 
@@ -1138,22 +1169,25 @@
 
 proc privacy::activate_privacy_list {depth connid} {
     variable options
-    variable answer
+    variable supported
 
+    set supported($connid) 0
+
     set_status [::msgcat::mc "Waiting for activating privacy list"]
     debugmsg privacy "requested privacy list activation"
     send_default_or_active_list "i-am-visible-list" active \
 	-command [list [namespace current]::get_answer $connid] \
 	-connection $connid
 
-    vwait [namespace current]::answer($connid,res)
+    lassign [wait_for_answer $connid] res child
 
-    switch -- $answer($connid,res) {
+    switch -- $res {
 	"OK" {
 	    set_status [::msgcat::mc "Privacy list is activated"]
+	    set supported($connid) 1
 	}
 	"ERR" {
-	    switch -- [lindex $answer($connid,error) 1] {
+	    switch -- [lindex [error_type_condition $child] 1] {
 		feature-not-implemented {
 		    # Privacy lists aren't implemented
 		    # Give up
@@ -1182,14 +1216,14 @@
 		    join_lists $connid "i-am-visible-list" \
 			{ignore-list invisible-list conference-list subscription-list} \
 			{allow {} {}} \
-			-command [list [namespace current]::get_answer \
-				       $connid]
+			-command [list [namespace current]::get_answer $connid]
 
-		    vwait [namespace current]::answer($connid,res)
+		    lassign [wait_for_answer $connid] res child
 
-		    switch -- $answer($connid,res) {
+		    switch -- $res {
 			"OK" {
 			    # Activate newly created list
+			    set supported($connid) 1
 			    return [activate_privacy_list [expr {$depth + 1}] \
 							  $connid]
 			}
@@ -1201,16 +1235,15 @@
 			    NonmodalMessageDlg .privacy_list_error$connid \
 				-aspect 50000 -icon error \
 				-title [::msgcat::mc "Privacy lists error"] \
-				-message [format \
+				-message \
 				    [::msgcat::mc \
 					"Creating default privacy list failed:\
 					 %s\n\nTry to reconnect. If problem\
 					 persists, you may want to disable privacy\
-					 list activation at start"] \
-				    $answer($connid,errormsg)]
+					 list activation at start" \
+				    [error_to_string $child]]
 
 			    logout $connid
-			    clear_answer $connid
 
 			    # Break connected_hook
 			    return stop
@@ -1219,7 +1252,6 @@
 			    # "DISCONNECT"
 			    set_status \
 				[::msgcat::mc "Privacy list is not created"]
-			    clear_answer $connid
 
 			    # Break connected_hook
 			    return stop
@@ -1235,16 +1267,15 @@
 		    NonmodalMessageDlg .privacy_list_error$connid \
 			-aspect 50000 -icon error \
 			-title [::msgcat::mc "Privacy lists error"] \
-			-message [format \
+			-message \
 			    [::msgcat::mc \
 				"Activating privacy list failed:\
 				 %s\n\nTry to reconnect. If problem\
 				 persists, you may want to disable privacy\
-				 list activation at start"] \
-			    $answer($connid,errormsg)]
+				 list activation at start" \
+			    [error_to_string $child]]
 
 		    logout $connid
-		    clear_answer $connid
 
 		    # Break connected_hook
 		    return stop
@@ -1254,16 +1285,15 @@
 	default {
 	    # "DISCONNECT"
 	    set_status [::msgcat::mc "Privacy list is not activated"]
-	    clear_answer $connid
 
 	    # Break connected_hook
 	    return stop
 	}
     }
-
-    clear_answer $connid
 }
 
+##########################################################################
+
 proc privacy::activate_privacy_list_at_startup {connid} {
     variable options
 
@@ -1275,21 +1305,22 @@
 hook::add connected_hook \
     [namespace current]::privacy::activate_privacy_list_at_startup 5
 
+##########################################################################
+
 proc privacy::get_answer {connid res child} {
     variable answer
     debugmsg privacy "got privacy list answer $connid $res $child"
 
-    if {$res == "ERR"} {
-	set answer($connid,error) [error_type_condition $child]
-	set answer($connid,errormsg) [error_to_string $child]
-    }
-    set answer($connid,res) $res
+    set answer($connid) [list $res $child]
 }
 
-proc privacy::clear_answer {connid} {
+proc privacy::wait_for_answer {connid} {
     variable answer
 
-    array unset answer $connid,*
+    vwait [namespace current]::answer($connid)
+    set res $answer($connid)
+    unset answer($connid)
+    return $res
 }
 
 ###############################################################################
@@ -1298,6 +1329,7 @@
     variable menu_messages
     variable special_list
     variable cboxes
+    variable supported
 
     set rjid [roster::find_jid $connid $jid]
 
@@ -1305,7 +1337,8 @@
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    if {[chat::is_groupchat [chat::chatid $connid $rjid]]} {
+    if {![info exists supported($connid)] || !$supported($connid) || \
+	    [chat::is_groupchat [chat::chatid $connid $rjid]]} {
 	set state disabled
     } else {
 	set state normal
@@ -1531,6 +1564,13 @@
 ###############################################################################
 
 proc privacy::enable_menu {connid} {
+    variable supported
+
+    set c [::jlib::route ""]
+    if {![info exists supported($c)] || !$supported($c)} {
+	return
+    }
+
     set m [.mainframe getmenu privacy]
     if {$::ifacetk::options(show_tearoffs)} {
 	set start 1
@@ -1543,8 +1583,12 @@
 }
 
 proc privacy::disable_menu {connid} {
-    if {[llength [jlib::connections]] > 0} return
+    variable supported
 
+    set c [::jlib::route ""]
+    if {[llength [jlib::connections]] > 0 && \
+	    [info exists supported($c)] && $supported($c)} return
+
     set m [.mainframe getmenu privacy]
     if {$::ifacetk::options(show_tearoffs)} {
 	set start 1

Modified: trunk/tkabber/trans/de.msg
===================================================================
--- trunk/tkabber/trans/de.msg	2007-03-06 17:14:10 UTC (rev 1021)
+++ trunk/tkabber/trans/de.msg	2007-03-06 17:45:41 UTC (rev 1022)
@@ -1,6 +1,6 @@
 # $Id$
 # German messages file
-# Roger Sondermann 26.02.2007
+# Roger Sondermann 06.03.2007
 
 # .../muc.tcl
 ::trans::trset de "Current rooms"                                           "Derzeitige Räume"
@@ -28,7 +28,7 @@
 ::trans::trset de "Away"                                                    "Abwesend"
 ::trans::trset de "Change Status"                                           "Status ändern"
 ::trans::trset de "Change status"                                           "Status ändern"
-::trans::trset de "Choose chats or groupchats from which you want to forward messages"       "Chats oder Konferenzen auswählen, von denen weitergeleitet werden soll"
+::trans::trset de "Choose chats or groupchats from which you want to forward messages" "Chats oder Konferenzen auswählen, von denen weitergeleitet werden soll"
 ::trans::trset de "Choose groupchats you want to leave"                     "Zu verlassene Konferenzen auswählen"
 ::trans::trset de "Choose status, priority, and status message"             "Priorität, Status und Status-Nachricht auswählen"
 ::trans::trset de "Do not disturb"                                          "Bitte nicht stören"



More information about the Tkabber-dev mailing list