[Tkabber-dev] r2155 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri May 2 21:25:40 MSK 2014


Author: sergei
Date: 2014-05-02 21:25:40 +0400 (Fri, 02 May 2014)
New Revision: 2155

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/presence.tcl
Log:
	* presence.tcl: Fixed caching maximum JID priority for a roster
	  contact.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2014-04-28 17:08:54 UTC (rev 2154)
+++ trunk/tkabber/ChangeLog	2014-05-02 17:25:40 UTC (rev 2155)
@@ -1,3 +1,8 @@
+2014-05-02  Sergei Golovan  <sgolovan at nes.ru>
+
+	* presence.tcl: Fixed caching maximum JID priority for a roster
+	  contact.
+
 2014-04-27  Sergei Golovan  <sgolovan at nes.ru>
 
 	* utils.tcl: Fixed typo in a comment.

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2014-04-28 17:08:54 UTC (rev 2154)
+++ trunk/tkabber/presence.tcl	2014-05-02 17:25:40 UTC (rev 2155)
@@ -131,19 +131,24 @@
 proc cache_preferred_jid_on_available {xlib jid user} {
     global presence
 
-    if {[info exists presence(maxpriority,$xlib,$user)]} {
-	set maxpri $presence(maxpriority,$xlib,$user)
-    } else {
+    set pri $presence(priority,$xlib,$jid)
+
+    if {![info exists presence(maxpriority,$xlib,$user)]} {
 	cache_preferred_jid $xlib $user
 	return
+    } elseif {$presence(preferred_jid,$xlib,$user) == $jid && \
+	      $pri < $presence(maxpriority,$xlib,$user)} {
+	unset presence(preferred_jid,$xlib,$user)
+	unset presence(maxpriority,$xlib,$user)
+	cache_preferred_jid $xlib $user
+	return
+    } else {
+	set maxpri $presence(maxpriority,$xlib,$user)
+	if {$pri > $maxpri} {
+	    set presence(maxpriority,$xlib,$user) $pri
+	    set presence(preferred_jid,$xlib,$user) $jid
+	}
     }
-    
-    set pri $presence(priority,$xlib,$jid)
-
-    if {$pri > $maxpri} {
-	set presence(maxpriority,$xlib,$user) $pri
-	set presence(preferred_jid,$xlib,$user) $jid
-    }
 }
 
 proc cache_preferred_jid_on_unavailable {xlib jid user} {



More information about the Tkabber-dev mailing list