[Tkabber-dev] r1579 - in trunk/tkabber: . ifacetk plugins/general plugins/roster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Oct 24 20:49:49 MSD 2008


Author: sergei
Date: 2008-10-24 20:49:49 +0400 (Fri, 24 Oct 2008)
New Revision: 1579

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/gpgme.tcl
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/ifacetk/iroster.tcl
   trunk/tkabber/login.tcl
   trunk/tkabber/plugins/general/sound.tcl
   trunk/tkabber/plugins/roster/cache_categories.tcl
   trunk/tkabber/presence.tcl
   trunk/tkabber/privacy.tcl
Log:
	* gpgme.tcl, ifacetk/iface.tcl, ifacetk/iroster.tcl, login.tcl,
	  plugins/general/sound.tcl, plugins/roster/cache_categories.tcl,
	  presence.tcl, privacy.tcl: Simplified procedures from
	  disconnected_hook (removed check for empty connection token
	  argument), optimized loading and storing roster group interface
	  settings.

	* ifacetk/iface.tcl: Fixed status_history option type.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/ChangeLog	2008-10-24 16:49:49 UTC (rev 1579)
@@ -1,3 +1,14 @@
+2008-10-24  Sergei Golovan  <sgolovan at nes.ru>
+
+	* gpgme.tcl, ifacetk/iface.tcl, ifacetk/iroster.tcl, login.tcl,
+	  plugins/general/sound.tcl, plugins/roster/cache_categories.tcl,
+	  presence.tcl, privacy.tcl: Simplified procedures from
+	  disconnected_hook (removed check for empty connection token
+	  argument), optimized loading and storing roster group interface
+	  settings.
+
+	* ifacetk/iface.tcl: Fixed status_history option type.
+
 2008-10-23  Sergei Golovan  <sgolovan at nes.ru>
 
 	* chats.tcl, ifacetk/iroster.tcl, login.tcl,

Modified: trunk/tkabber/gpgme.tcl
===================================================================
--- trunk/tkabber/gpgme.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/gpgme.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -1170,11 +1170,7 @@
 proc ::ssj::clear_signatures {xlib} {
     variable signed
 
-    if {$xlib == {}} {
-	catch {array unset signed}
-    } else {
-	catch {array unset signed $xlib,*}
-    }
+    array unset signed $xlib,*
 }
 
 hook::add disconnected_hook ::ssj::clear_signatures

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/ifacetk/iface.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -98,7 +98,7 @@
 
     custom::defvar status_history [list] \
 	    [::msgcat::mc "History of availability status messages"] \
-	    -type list \
+	    -type string \
 	    -group Hidden
 
     custom::defvar options(max_status_history) 10 \
@@ -691,7 +691,7 @@
     .ssl_info draw
 }
 
-proc ifacetk::update_ssl_ind {args} {
+proc ifacetk::update_ssl_ind {xlib} {
     global use_tls
     variable ssl_ind
 

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/ifacetk/iroster.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -129,100 +129,90 @@
     variable own_resources_group_name $roster::own_resources_group_name
 }
 
-proc roster::get_group_lists {} {
+proc roster::get_group_lists {xlib} {
     variable collapsed_group_list
     variable show_offline_group_list
-    variable collapsed
-    variable show_offline
+    variable options
+    variable roster
 
-    foreach {jid grlist} $collapsed_group_list {
-	foreach {group val} $grlist {
-	    set collapsed($jid,$group) $val
+    set jid [::xmpp::jid::normalize [connection_bare_jid $xlib]]
+    array set c $collapsed_group_list
+    array set s $show_offline_group_list
+
+    if {[info exists c($jid)]} {
+	foreach {group val} $c($jid) {
+	    if {$options(nested)} {
+		set gid [list $xlib [msplit $group $options(nested_delimiter)]]
+	    } else {
+		set gid [list $xlib [list $group]]
+	    }
+	    set roster(collapsed,$gid) $val
 	}
     }
-    foreach {jid grlist} $show_offline_group_list {
-	foreach {group val} $grlist {
-	    set show_offline($jid,$group) $val
+
+    if {[info exists s($jid)]} {
+	foreach {group val} $s($jid) {
+	    set gid [list $xlib $group]
+	    set roster(show_offline,$gid) $val
 	}
     }
 }
 
-hook::add finload_hook [namespace current]::roster::get_group_lists
+hook::add connected_hook [namespace current]::roster::get_group_lists 1
 
 proc roster::set_group_lists {xlib} {
     variable collapsed_group_list
     variable show_offline_group_list
-    variable collapsed
-    variable show_offline
-    variable roster
     variable options
+    variable roster
     variable undef_group_name
     variable chats_group_name
 
-    set _collapsed_group_list $collapsed_group_list
-    set _show_offline_group_list $show_offline_group_list
+    set jid [::xmpp::jid::normalize [connection_bare_jid $xlib]]
+    array set c $collapsed_group_list
+    array set s $show_offline_group_list
 
-    if {$xlib == {}} {
-	set xliblist [connections]
-    } else {
-	set xliblist [list $xlib]
-    }
+    set groups [roster::get_groups $xlib -raw 1]
+    lappend groups $undef_group_name $chats_group_name
 
-    foreach xlib $xliblist {
-	if {[catch { set bare_jid [connection_bare_jid $xlib] }]} {
-	    continue
-	}
-	if {[catch { set groups [roster::get_groups $xlib -raw 1] }]} {
-	    continue
-	}
-	if {$options(nested)} {
-	    set tmp {}
-	    foreach group $groups {
-		set tmp1 [msplit $group $options(nested_delimiter)]
-		for {set i 0} {$i < [llength $tmp1]} {incr i} {
-		    lappend tmp [lrange $tmp1 0 $i]
-		}
-	    }
-	    set groups [lrmdups $tmp]
-	}
-	lappend groups $undef_group_name $chats_group_name
-	set tmpc {}
-	set tmps {}
+    if {$options(nested)} {
+	set tmp {}
 	foreach group $groups {
-	    if {$options(nested)} {
-		set grname [join $group $options(nested_delimiter)]
-		set gid [list $xlib $group]
-	    } else {
-		set grname [list $group]
-		set gid [list $xlib $grname]
+	    set tmp1 [msplit $group $options(nested_delimiter)]
+	    for {set i 0} {$i < [llength $tmp1]} {incr i} {
+		lappend tmp [lrange $tmp1 0 $i]
 	    }
-	    if {[info exists roster(collapsed,$gid)]} {
-		set collapsed($bare_jid,$grname) $roster(collapsed,$gid)
-		lappend tmpc $grname $roster(collapsed,$gid)
-	    }
-	    if {[info exists roster(show_offline,$gid)]} {
-		set show_offline($bare_jid,$grname) $roster(show_offline,$gid)
-		lappend tmps $grname $roster(show_offline,$gid)
-	    }
 	}
-	if {![lempty $tmpc]} {
-	    while {[set idx [lsearch -exact $_collapsed_group_list $bare_jid]] >= 0} {
-		set _collapsed_group_list \
-		    [lreplace $_collapsed_group_list $idx [expr {$idx + 1}]]
-	    }
-	    lappend _collapsed_group_list $bare_jid $tmpc
+	set groups [lrmdups $tmp]
+    }
+
+    set c($jid) {}
+    set s($jid) {}
+    foreach group $groups {
+	if {$options(nested)} {
+	    set grname [join $group $options(nested_delimiter)]
+	    set gid [list $xlib $group]
+	} else {
+	    set grname $group
+	    set gid [list $xlib [list $group]]
 	}
-	if {![lempty $tmps]} {
-	    while {[set idx [lsearch -exact $_show_offline_group_list $bare_jid]] >= 0} {
-		set _show_offline_group_list \
-		    [lreplace $_show_offline_group_list $idx [expr {$idx + 1}]]
-	    }
-	    lappend _show_offline_group_list $bare_jid $tmps
+	if {[info exists roster(collapsed,$gid)] && $roster(collapsed,$gid)} {
+	    lappend c($jid) $grname $roster(collapsed,$gid)
 	}
+	if {[info exists roster(show_offline,$gid)] && $roster(show_offline,$gid)} {
+	    lappend s($jid) $grname $roster(show_offline,$gid)
+	}
     }
 
-    set collapsed_group_list $_collapsed_group_list
-    set show_offline_group_list $_show_offline_group_list
+    if {[llength $c($jid)] == 0} {
+	unset c($jid)
+    }
+    if {[llength $s($jid)] == 0} {
+	unset s($jid)
+    }
+
+    set collapsed_group_list [array get c]
+    set show_offline_group_list [array get s]
 }
 
 hook::add disconnected_hook [namespace current]::roster::set_group_lists 40
@@ -285,8 +275,6 @@
     variable undef_group_name
     variable chats_group_name
     variable own_resources_group_name
-    variable collapsed
-    variable show_offline
 
     clear .roster 0
     
@@ -454,16 +442,7 @@
 	    set group [lindex $group 1]
 	    set gid [list $xlib $group]
 	    if {![info exists roster(show_offline,$gid)]} {
-		if {$options(nested)} {
-		    set gname [join $group $options(nested_delimiter)]
-		} else {
-		    set gname $group
-		}
-		if {[info exists show_offline($bare_jid,$gname)]} {
-		    set roster(show_offline,$gid) $show_offline($bare_jid,$gname)
-		} else {
-		    set roster(show_offline,$gid) 0
-		}
+		set roster(show_offline,$gid) 0
 	    }
 	}
 	foreach group $groups {
@@ -472,16 +451,7 @@
 	    set groupsundergroup($group) [lrmdups $groupsundergroup($group)]
 	    set gid [list $xlib $group]
 	    if {![info exists roster(collapsed,$gid)]} {
-		if {$options(nested)} {
-		    set gname [join $group $options(nested_delimiter)]
-		} else {
-		    set gname $group
-		}
-		if {[info exists collapsed($bare_jid,$gname)]} {
-		    set roster(collapsed,$gid) $collapsed($bare_jid,$gname)
-		} else {
-		    set roster(collapsed,$gid) 0
-		}
+		set roster(collapsed,$gid) 0
 	    }
 	    set indent [expr {[llength $group] - 1}]
 	    set collapse 0

Modified: trunk/tkabber/login.tcl
===================================================================
--- trunk/tkabber/login.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/login.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -251,7 +251,7 @@
     set connections [lreplace $connections $idx $idx]
 }
 
-hook::add disconnected_hook remove_from_connection 90
+hook::add disconnected_hook remove_from_connection 1
 
 proc connection_jid {xlib} {
     global connjid

Modified: trunk/tkabber/plugins/general/sound.tcl
===================================================================
--- trunk/tkabber/plugins/general/sound.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/plugins/general/sound.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -297,15 +297,7 @@
 
     if {[is_mute]} return
 
-    if {$xlib == {}} {
-	if {[llength [connections]] > 0} {
-	    play $sounds(disconnected) 1
-	}
-    } else {
-	if {[lsearch -exact [connections] $xlib] >= 0} {
-	    play $sounds(disconnected) 1
-	}
-    }
+    play $sounds(disconnected) 1
 }
 
 proc ::sound::is_mute {} {

Modified: trunk/tkabber/plugins/roster/cache_categories.tcl
===================================================================
--- trunk/tkabber/plugins/roster/cache_categories.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/plugins/roster/cache_categories.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -33,11 +33,7 @@
     variable category_and_subtype_list
     variable requested_categories
 
-    if {$xlib == {}} {
-	array unset requested_categories
-    } else {
-	catch { unset requested_categories($xlib) }
-    }
+    catch { unset requested_categories($xlib) }
 }
 
 hook::add disconnected_hook \

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/presence.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -343,20 +343,6 @@
 
 ###############################################################################
 
-proc change_presence_on_disconnect {xlib} {
-    if {[connections] == {}} {
-	set_status "Disconnected"
-
-	set curuserstatus unavailable
-	set userstatusdesc [::msgcat::mc "Not logged in"]
-	hook::run change_our_presence_post_hook unavailable
-    }
-}
-
-hook::add disconnected_hook change_presence_on_disconnect 100
-
-###############################################################################
-
 trace variable userstatus w change_our_presence
 trace variable logoutuserstatus w change_our_presence
 
@@ -569,20 +555,23 @@
 proc clear_presence_info {xlib} {
     global presence
 
-    if {$xlib == {}} {
-	array unset presence
-    } else {
-	# TODO
-	array unset presence type,$xlib,*
-	array unset presence status,$xlib,*
-	array unset presence priority,$xlib,*
-	array unset presence show,$xlib,*
-	array unset presence error,$xlib,*
-	array unset presence x,$xlib,*
-	array unset presence user_jids,$xlib,*
-	array unset presence preferred_jid,$xlib,*
-	array unset presence cachedstatus,$xlib,*
-	array unset presence maxpriority,$xlib,*
+    array unset presence type,$xlib,*
+    array unset presence status,$xlib,*
+    array unset presence priority,$xlib,*
+    array unset presence show,$xlib,*
+    array unset presence error,$xlib,*
+    array unset presence x,$xlib,*
+    array unset presence user_jids,$xlib,*
+    array unset presence preferred_jid,$xlib,*
+    array unset presence cachedstatus,$xlib,*
+    array unset presence maxpriority,$xlib,*
+
+    if {[connections] == {}} {
+	set_status "Disconnected"
+
+	set curuserstatus unavailable
+	set userstatusdesc [::msgcat::mc "Not logged in"]
+	hook::run change_our_presence_post_hook unavailable
     }
 }
 

Modified: trunk/tkabber/privacy.tcl
===================================================================
--- trunk/tkabber/privacy.tcl	2008-10-24 16:43:10 UTC (rev 1578)
+++ trunk/tkabber/privacy.tcl	2008-10-24 16:49:49 UTC (rev 1579)
@@ -1319,11 +1319,7 @@
 proc privacy::clear_supported {xlib} {
     variable supported
 
-    if {$xlib == ""} {
-	catch { array unset supported * }
-    } else {
-	catch { array unset supported $xlib }
-    }
+    array unset supported $xlib
 }
 
 hook::add disconnected_hook [namespace current]::privacy::clear_supported
@@ -1473,13 +1469,8 @@
     variable special_list
     variable cboxes
 
-    if {$xlib == ""} {
-	catch { array unset special_list * }
-	catch { array unset cboxes * }
-    } else {
-	catch { array unset special_list $xlib,* }
-	catch { array unset cboxes $xlib,* }
-    }
+    array unset special_list $xlib,*
+    array unset cboxes $xlib,*
 }
 
 hook::add disconnected_hook [namespace current]::privacy::clear_list_vars



More information about the Tkabber-dev mailing list