[Tkabber-dev] r1079 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Apr 1 16:42:19 MSD 2007


Author: sergei
Date: 2007-04-01 16:42:18 +0400 (Sun, 01 Apr 2007)
New Revision: 1079

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/privacy.tcl
Log:
	* privacy.tcl: Ensure conference list loading before any join room
	  attempt is made. Without that it would be possible for conference
	  list to become empty if there are autojoined conferences in
	  bookmarks or if a user loads Tkabber's state on start.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-04-01 05:09:04 UTC (rev 1078)
+++ trunk/tkabber/ChangeLog	2007-04-01 12:42:18 UTC (rev 1079)
@@ -2,6 +2,11 @@
 
 	* contrib/starkit/README: Fixed double README.
 
+	* privacy.tcl: Ensure conference list loading before any join room
+	  attempt is made. Without that it would be possible for conference
+	  list to become empty if there are autojoined conferences in
+	  bookmarks or if a user loads Tkabber's state on start.
+
 2007-03-31  Sergei Golovan  <sgolovan at nes.ru>
 
 	* contrib/starkit/main.tcl: Fixed usage of starkit::topdir variable,

Modified: trunk/tkabber/privacy.tcl
===================================================================
--- trunk/tkabber/privacy.tcl	2007-04-01 05:09:04 UTC (rev 1078)
+++ trunk/tkabber/privacy.tcl	2007-04-01 12:42:18 UTC (rev 1079)
@@ -824,9 +824,8 @@
 proc privacy::send_special_list {connid name items} {
     variable special_list
     variable cboxes
-    variable supported
 
-    if {![info exists supported($connid)] || !$supported($connid)} {
+    if {![is_supported $connid]} {
 	return
     }
 
@@ -905,9 +904,8 @@
 # not from the roster.
 proc privacy::send_subscription_list {connid} {
     variable accept_from_roster_only
-    variable supported
 
-    if {![info exists supported($connid)] || !$supported($connid)} {
+    if {![is_supported $connid]} {
 	return
     }
 
@@ -1171,10 +1169,7 @@
 
 proc privacy::activate_privacy_list {depth connid} {
     variable options
-    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 \
@@ -1186,7 +1181,7 @@
     switch -- $res {
 	"OK" {
 	    set_status [::msgcat::mc "Privacy list is activated"]
-	    set supported($connid) 1
+	    set_supported $connid
 	}
 	"ERR" {
 	    switch -- [lindex [error_type_condition $child] 1] {
@@ -1225,7 +1220,7 @@
 		    switch -- $res {
 			"OK" {
 			    # Activate newly created list
-			    set supported($connid) 1
+			    set_supported $connid
 			    return [activate_privacy_list [expr {$depth + 1}] \
 							  $connid]
 			}
@@ -1327,11 +1322,36 @@
 
 ###############################################################################
 
+proc privacy::is_supported {connid} {
+    variable supported
+
+    expr {[info exists supported($connid)] && $supported($connid)}
+}
+
+proc privacy::set_supported {connid} {
+    variable supported
+
+    set supported($connid) 1
+}
+
+proc privacy::clear_supported {connid} {
+    variable supported
+
+    if {$connid == ""} {
+	catch { array unset supported * }
+    } else {
+	catch { array unset supported $connid }
+    }
+}
+
+hook::add disconnected_hook [namespace current]::privacy::clear_supported
+
+###############################################################################
+
 proc privacy::create_menu {m connid jid} {
     variable menu_messages
     variable special_list
     variable cboxes
-    variable supported
 
     set rjid [roster::find_jid $connid $jid]
 
@@ -1339,7 +1359,7 @@
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    if {![info exists supported($connid)] || !$supported($connid) || \
+    if {![is_supported $connid] || \
 	    [chat::is_groupchat [chat::chatid $connid $rjid]]} {
 	set state disabled
     } else {
@@ -1483,9 +1503,34 @@
 hook::add disconnected_hook [namespace current]::privacy::clear_list_vars
 
 ###############################################################################
+# Conference list should be loaded before any join group attempt is made
 
+proc privacy::get_conference_list {connid} {
+    jlib::send_iq get \
+	[jlib::wrapper:createtag query \
+	     -vars [list xmlns $::NS(privacy)] \
+	     -subtags [list [jlib::wrapper:createtag list \
+				 -vars [list name "conference-list"]]]] \
+	-command [list [namespace current]::get_answer $connid] \
+	-connection $connid
+
+    lassign [wait_for_answer $connid] res child
+
+    if {($res == "OK") || \
+	    ($res == "ERR" && \
+	     [lindex [error_type_condition $child] 1] == "item-not-found")} {
+	set_supported $connid
+    }
+
+    store_special_list $connid conference $res $child
+}
+
+hook::add connected_hook [namespace current]::privacy::get_conference_list 2
+
+###############################################################################
+
 proc privacy::get_list_vars {connid} {
-    foreach name {invisible visible ignore conference} {
+    foreach name {invisible visible ignore} {
 	reload_special_list $connid $name
     }
     reload_subscription_list $connid
@@ -1566,10 +1611,8 @@
 ###############################################################################
 
 proc privacy::enable_menu {connid} {
-    variable supported
-
     set c [::jlib::route ""]
-    if {![info exists supported($c)] || !$supported($c)} {
+    if {![is_supported $c]} {
 	return
     }
 
@@ -1585,11 +1628,8 @@
 }
 
 proc privacy::disable_menu {connid} {
-    variable supported
-
     set c [::jlib::route ""]
-    if {[llength [jlib::connections]] > 0 && \
-	    [info exists supported($c)] && $supported($c)} return
+    if {[llength [jlib::connections]] > 0 && [is_supported $c]} return
 
     set m [.mainframe getmenu privacy]
     if {$::ifacetk::options(show_tearoffs)} {



More information about the Tkabber-dev mailing list