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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Sep 10 22:02:00 MSD 2006


Author: sergei
Date: 2006-09-10 22:01:50 +0400 (Sun, 10 Sep 2006)
New Revision: 710

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/disco.tcl
   trunk/tkabber/ifacetk/iroster.tcl
   trunk/tkabber/plugins/roster/cache_categories.tcl
   trunk/tkabber/plugins/roster/conferences.tcl
   trunk/tkabber/roster.tcl
Log:
	* disco.tcl: Added displaying number of items in every node's
	  title where this number is sufficiently large.

	* plugins/roster/conferences.tcl: Fixed race confition during
	  autojoining conferences.

	* plugins/roster/cache_categories.tcl, roster.tcl: Fixed race
	  condition when overriding servers categories and types.
	  Made overriding scheme more robust.

	* chats.tcl: Fixed status icon behavior (transport icons are
	  not replaced by ordinary icons anymore).

	* ifacetk/iroster.tcl: Added optional argument (status) to
	  get_jid_icon.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/ChangeLog	2006-09-10 18:01:50 UTC (rev 710)
@@ -8,8 +8,21 @@
 	  joining it.
 
 	* disco.tcl: Added displaying number of items in every node's
-	  title.
+	  title where this number is sufficiently large.
 
+	* plugins/roster/conferences.tcl: Fixed race confition during
+	  autojoining conferences.
+
+	* plugins/roster/cache_categories.tcl, roster.tcl: Fixed race
+	  condition when overriding servers categories and types.
+	  Made overriding scheme more robust.
+
+	* chats.tcl: Fixed status icon behavior (transport icons are
+	  not replaced by ordinary icons anymore).
+
+	* ifacetk/iroster.tcl: Added optional argument (status) to
+	  get_jid_icon.
+
 2006-09-09  Sergei Golovan  <sgolovan at nes.ru>
 
 	* browser.tcl, disco.tcl: Removed hardcoded icon names

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/chats.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -362,18 +362,21 @@
 
     foreach chatid $chats(opened) {
 	if {[cequal $connid {}] || [cequal [get_connid $chatid] $connid]} {
+	    set jid [get_jid $chatid]
+
 	    set chatw [chat_win $chatid]
 	    if {[winfo exists $chatw] && \
 		    $chats(status,$chatid) != "disconnected"} {
 		set chats(status,$chatid) disconnected
-		add_message $chatid [get_jid $chatid] error \
+		add_message $chatid $jid error \
 		    [::msgcat::mc "Disconnected"] {}
 	    }
 
 	    set cw [winid $chatid]
 
 	    if {[winfo exists $cw.status.icon]} {
-		$cw.status.icon configure -image roster/user/unavailable \
+		$cw.status.icon configure \
+		    -image [ifacetk::roster::get_jid_icon $connid $jid unavailable] \
 		    -helptext ""
 	    }
 
@@ -385,7 +388,7 @@
     }
 }
 
-hook::add disconnected_hook [namespace current]::chat::disconnect_groupchats 99
+hook::add predisconnected_hook [namespace current]::chat::disconnect_groupchats 99
 
 proc chat::open_window {chatid type args} {
     global font font_bold font_italic font_bold_italic
@@ -462,7 +465,7 @@
     if {[cequal $type chat]} {
 	set status [get_user_status $connid $jid]
 	Label $cw.status.icon \
-	    -image [ifacetk::roster::get_jid_icon $connid $jid] \
+	    -image [ifacetk::roster::get_jid_icon $connid $jid $status] \
 	    -helptext [get_user_status_desc $connid $jid]
 	pack $cw.status.icon -side left
 	if {$options(display_status_description)} {
@@ -1111,7 +1114,8 @@
     set cw [winid [chatid $connid $jid]]
 
     if {[winfo exists $cw.status.icon]} {
-	$cw.status.icon configure -image roster/user/$status \
+	$cw.status.icon configure \
+	    -image [ifacetk::roster::get_jid_icon $connid $jid $status] \
 	    -helptext [get_user_status_desc $connid $jid]
     }
 
@@ -1125,7 +1129,9 @@
 
     if {[winfo exists $cw.status.icon]} {
 	$cw.status.icon configure \
-	    -image roster/user/[get_user_status $connid $user]
+	    -image [ifacetk::roster::get_jid_icon \
+			$connid $user [get_user_status $connid $user]] \
+	    -helptext [get_user_status_desc $connid $user]
     }
 }
 

Modified: trunk/tkabber/disco.tcl
===================================================================
--- trunk/tkabber/disco.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/disco.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -402,6 +402,13 @@
 
     image create photo ""
 
+    variable options
+
+    # Do not show items number in node title if this number
+    # is not greater than 20
+    # (It is questionnable whether to add this option to Customize).
+    set options(upper_items_bound) 20
+
     custom::defvar disco_list {} [::msgcat::mc "List of discovered JIDs."] \
 	    -group Hidden
     custom::defvar node_list {} [::msgcat::mc "List of discovered JID nodes."] \
@@ -852,12 +859,14 @@
 }
 
 proc disco::browser::item_desc {jid node name nitems} {
+    variable options
+
     if {$node != ""} {
 	set snode " \[$node\]"
     } else {
 	set snode ""
     }
-    if {$nitems > 0} {
+    if {$nitems > $options(upper_items_bound)} {
 	set sitems " - $nitems"
     } else {
 	set sitems ""

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/ifacetk/iroster.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -624,18 +624,50 @@
     }
 }
 
-proc roster::get_jid_icon {connid jid} {
+proc roster::get_service_foreground {connid service type} {
+    switch -- $type {
+	jud {return ""}
+	}
+    if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
+	return [get_user_status $connid $service]
+    } else {
+	return unsubscribed
+    }
+}
+
+proc roster::get_user_foreground {connid user} {
+    set status [get_user_aliases_status $connid $user]
+
+    set subsc [::roster::itemconfig $connid $user -subsc]
+    if {[cequal $subsc ""]} {
+	set subsc [::roster::itemconfig $connid \
+		       [::roster::find_jid $connid $user] -subsc]
+    }
+
+    if {([cequal $subsc from] || [cequal $subsc none]) && \
+	    $status == "unavailable"} {
+	return unsubscribed
+    } else {
+	return $status
+    }
+}
+
+proc roster::get_jid_icon {connid jid {status ""}} {
     lassign [::roster::get_category_and_subtype $connid $jid] category type
 
     switch -- $category {
-	"" {
-	    return [get_user_icon $connid $jid]
-	}
+	"" -
 	user {
-	    return [get_user_icon $connid $jid]
+	    if {$status == ""} {
+		set status [get_user_aliases_status $connid $jid]
+	    }
+	    return [get_user_icon $connid $jid $status]
 	}
 	conference {
-	    if {[get_jid_status $connid $jid] != "unavailable"} {
+	    if {$status == ""} {
+		set status [get_jid_status $connid $jid]
+	    }
+	    if {$status != "unavailable"} {
 		return roster/conference/available
 	    }
 	    return roster/conference/unavailable
@@ -643,7 +675,10 @@
 	server  -
 	gateway -
 	service {
-		return [get_service_icon $connid $jid $type]
+	    if {$status == ""} {
+		set status [get_user_status $connid $jid]
+	    }
+	    return [get_service_icon $connid $jid $type $status]
 	}
 	default {
 	    return ""
@@ -651,7 +686,7 @@
     }
 }
 
-proc roster::get_service_icon {connid service type} {
+proc roster::get_service_icon {connid service type status} {
     variable show_transport_icons
 
     if {$show_transport_icons} {
@@ -660,7 +695,6 @@
 	    sms {return services/sms}
 	}
 	if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
-	    set status [get_user_status $connid $service]
 	    if {![catch { image type services/$type/$status }]} {
 		return services/$type/$status
 	    } else {
@@ -671,46 +705,16 @@
 	}
     } else {
 	if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
-	    return roster/user/[get_user_status $connid $service]
+	    return roster/user/$status
 	} else {
 	    return roster/user/unsubscribed
 	}
     }
 }
 
-proc roster::get_service_foreground {connid service type} {
-    switch -- $type {
-	jud {return ""}
-	}
-    if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
-	return [get_user_status $connid $service]
-    } else {
-	return unsubscribed
-    }
-}
-
-proc roster::get_user_foreground {connid user} {
-    set status [get_user_aliases_status $connid $user]
-
-    set subsc [::roster::itemconfig $connid $user -subsc]
-    if {[cequal $subsc ""]} {
-	set subsc [::roster::itemconfig $connid \
-		       [::roster::find_jid $connid $user] -subsc]
-    }
-
-    if {([cequal $subsc from] || [cequal $subsc none]) && \
-	    $status == "unavailable"} {
-	return unsubscribed
-    } else {
-	return $status
-    }
-}
-
-proc roster::get_user_icon {connid user} {
+proc roster::get_user_icon {connid user status} {
     variable show_transport_user_icons
 
-    set status [get_user_aliases_status $connid $user]
-
     set subsc [::roster::itemconfig $connid $user -subsc]
     if {[cequal $subsc ""]} {
 	set subsc [::roster::itemconfig $connid \

Modified: trunk/tkabber/plugins/roster/cache_categories.tcl
===================================================================
--- trunk/tkabber/plugins/roster/cache_categories.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/plugins/roster/cache_categories.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -25,7 +25,7 @@
 }
 
 hook::add connected_hook \
-    [namespace current]::cache_categories::fill_cached_categories_and_subtypes
+    [namespace current]::cache_categories::fill_cached_categories_and_subtypes 5
 
 ##############################################################################
 
@@ -85,12 +85,6 @@
 		lappend category_and_subtype_list \
 			$server [list $category $type]
 
-		foreach jid [roster::get_jids $connid] {
-		    if {[server_from_jid $jid] == $server} {
-			roster::heuristically_get_category_and_subtype $connid $jid
-		    }
-		}
-
 		custom::store_vars [namespace current]::category_and_subtype_list
 		::redraw_roster
 		break

Modified: trunk/tkabber/plugins/roster/conferences.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferences.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/plugins/roster/conferences.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -677,7 +677,7 @@
     } else {
 	set password ""
     }
-    muc::join_group $connid $jid $nick $password
+    after idle [list muc::join_group $connid $jid $nick $password]
 }
 
 ###############################################################################

Modified: trunk/tkabber/roster.tcl
===================================================================
--- trunk/tkabber/roster.tcl	2006-09-09 20:14:00 UTC (rev 709)
+++ trunk/tkabber/roster.tcl	2006-09-10 18:01:50 UTC (rev 710)
@@ -295,20 +295,34 @@
 proc roster::override_category_and_subtype {connid jid category subtype} {
     variable roster
 
-    set roster(cached_category_and_subtype,$connid,$jid) \
+    set roster(overridden_category_and_subtype,$connid,$jid) \
 	[list $category $subtype]
 }
 
 proc roster::get_category_and_subtype {connid jid} {
     variable roster
 
+    if {[info exists roster(overridden_category_and_subtype,$connid,$jid)]} {
+	return $roster(overridden_category_and_subtype,$connid,$jid)
+    }
+
+    set server [server_from_jid $jid]
+    if {[info exists roster(overridden_category_and_subtype,$connid,$server)]} {
+	catch { unset roster(cached_category_and_subtype,$connid,$jid) }
+	set cs [heuristically_get_category_and_subtype $connid $jid]
+	set roster(overridden_category_and_subtype,$connid,$jid) $cs
+	return $cs
+    }
+
     if {[info exists roster(cached_category_and_subtype,$connid,$jid)]} {
 	return $roster(cached_category_and_subtype,$connid,$jid)
     }
 
     catch { plugins::cache_categories::request_category_and_subtype $connid $jid }
 
-    return [heuristically_get_category_and_subtype $connid $jid]
+    set cs [heuristically_get_category_and_subtype $connid $jid]
+    set roster(cached_category_and_subtype,$connid,$jid) $cs
+    return $cs
 }
 
 proc roster::heuristically_get_category_and_subtype {connid jid} {
@@ -316,8 +330,9 @@
 
     set node [node_from_jid $jid]
     set server [server_from_jid $jid]
+    set resource [resource_from_jid $jid]
 
-    if {$node == ""} {
+    if {$node == "" && $resource == ""} {
 	set updomain [lindex [split $server .] 0]
 	set category service
 
@@ -349,10 +364,13 @@
 	    }
 	}
 
-	set roster(cached_category_and_subtype,$connid,$jid) [list $category $subtype]
 	return [list $category $subtype]
     }
 
+    if {$node == ""} {
+	return [get_category_and_subtype $connid $server]
+    }
+
     if {[resource_from_jid $jid] == ""} {
 	lassign [get_category_and_subtype $connid $server] scategory ssubtype
 
@@ -376,11 +394,9 @@
 	    }
 	}
 
-	set roster(cached_category_and_subtype,$connid,$jid) [list $category $subtype]
 	return [list $category $subtype]
     }
 
-    set roster(cached_category_and_subtype,$connid,$jid) {user client}
     return {user client}
 }
 
@@ -395,6 +411,7 @@
     array unset roster category,*
     array unset roster subtype,*
     array unset roster cached_category_and_subtype,*
+    array unset roster overridden_category_and_subtype,*
     ::redraw_roster
 }
 
@@ -409,6 +426,7 @@
     array unset roster category,$connid,*
     array unset roster subtype,$connid,*
     array unset roster cached_category_and_subtype,$connid,*
+    array unset roster overridden_category_and_subtype,$connid,*
 
     ::redraw_roster
 }



More information about the Tkabber-dev mailing list