[Tkabber-dev] r1982 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Oct 5 10:18:18 MSD 2011


Author: sergei
Date: 2011-10-05 10:18:18 +0400 (Wed, 05 Oct 2011)
New Revision: 1982

Added:
   trunk/tkabber/plugins/general/nickname.tcl
Removed:
   trunk/tkabber/plugins/general/jitworkaround.tcl
Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/namespaces.tcl
Log:
	* namespaces.tcl, plugins/general/nickname.tcl: Added support for
	  XEP-0172, user nicknames (thanks to Vitaly Takmazov).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2011-10-04 16:14:28 UTC (rev 1981)
+++ trunk/tkabber/ChangeLog	2011-10-05 06:18:18 UTC (rev 1982)
@@ -1,3 +1,8 @@
+2011-10-05  Sergei Golovan  <sgolovan at nes.ru>
+
+	* namespaces.tcl, plugins/general/nickname.tcl: Added support for
+	  XEP-0172, user nicknames (thanks to Vitaly Takmazov).
+
 2011-10-04  Sergei Golovan  <sgolovan at nes.ru>
 
 	* ifacetk/systray.tcl, presence.tcl: Introduced new hook

Modified: trunk/tkabber/namespaces.tcl
===================================================================
--- trunk/tkabber/namespaces.tcl	2011-10-04 16:14:28 UTC (rev 1981)
+++ trunk/tkabber/namespaces.tcl	2011-10-05 06:18:18 UTC (rev 1982)
@@ -31,6 +31,7 @@
 	bookmarks   "storage:bookmarks" \
 	tkabber:groups "tkabber:bookmarks:groups" \
 	pubsub      "http://jabber.org/protocol/pubsub" \
+	nick        "http://jabber.org/protocol/nick" \
     ]
 }
 

Deleted: trunk/tkabber/plugins/general/jitworkaround.tcl
===================================================================
--- trunk/tkabber/plugins/general/jitworkaround.tcl	2011-10-04 16:14:28 UTC (rev 1981)
+++ trunk/tkabber/plugins/general/jitworkaround.tcl	2011-10-05 06:18:18 UTC (rev 1982)
@@ -1,58 +0,0 @@
-# $Id$
-
-###############################################################################
-# JIT workaround: when receving <presence/> stanza with name attribute and
-# roster item doesn't have name, fill the name
-#
-
-namespace eval jitworkaround {}
-
-proc jitworkaround::process_subscribed {xlib from type x args} {
-    variable names
-
-    if {$type != "subscribed"} return
-
-    set newname ""
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -name { set newname $val }
-	}
-    }
-
-    if {$newname == ""} return
-
-    set jid [roster::find_jid $xlib $from]
-
-    if {$jid == ""} {
-	set names($xlib,$from) $newname
-    } elseif {[roster::itemconfig $xlib $jid -name] == ""} {
-	roster::itemconfig $xlib $jid -name $newname
-	roster::send_item $xlib $jid
-	::redraw_roster
-    }
-}
-
-hook::add client_presence_hook \
-	  [namespace current]::jitworkaround::process_subscribed
-
-###############################################################################
-
-proc jitworkaround::set_received_name {xlib jid name groups subsc ask} {
-    variable names
-
-    if {$subsc == "remove"} return
-
-    if {[info exists names($xlib,$jid)]} {
-	if {[roster::itemconfig $xlib $jid -name] == ""} {
-	    roster::itemconfig $xlib $jid -name $names($xlib,$jid)
-	    roster::send_item $xlib $jid
-	}
-	unset names($xlib,$jid)
-    }
-}
-
-hook::add roster_push_hook \
-	  [namespace current]::jitworkaround::set_received_name 60
-
-###############################################################################
-

Copied: trunk/tkabber/plugins/general/nickname.tcl (from rev 1980, trunk/tkabber/plugins/general/jitworkaround.tcl)
===================================================================
--- trunk/tkabber/plugins/general/nickname.tcl	                        (rev 0)
+++ trunk/tkabber/plugins/general/nickname.tcl	2011-10-05 06:18:18 UTC (rev 1982)
@@ -0,0 +1,72 @@
+# $Id$
+###############################################################################
+# XEP-0172: User Nickname
+
+namespace eval nick {}
+
+proc nick::process_presence {xlib from type x args} {
+    variable names
+
+    set newname ""
+
+    switch -- $type {
+    subscribe -
+    subscribed -
+	available {
+	    foreach xs $x {
+		::xmpp::xml::split $xs tag xmlns attrs cdata subels
+		if {[string equal $xmlns $::NS(nick)]} {
+		    set newname $cdata
+		}
+	    }
+	}
+    }
+
+
+    if {$type == "subscribed"} {
+	# JIT workaround: when receving <presence/> stanza with name attribute and
+	# roster item doesn't have name, fill the name
+        foreach {opt val} $args {
+	       switch -- $opt {
+	           -name { set newname $val }
+	       }
+        }
+    }
+
+    if {$newname == ""} return
+
+    set jid [roster::find_jid $xlib $from]
+
+    if {$jid == ""} {
+	set names($xlib,$from) $newname
+    } elseif {[roster::itemconfig $xlib $jid -name] == ""} {
+	roster::itemconfig $xlib $jid -name $newname
+	roster::send_item $xlib $jid
+	::redraw_roster
+    }
+}
+
+hook::add client_presence_hook \
+	  [namespace current]::nick::process_presence
+
+###############################################################################
+
+proc nick::set_received_name {xlib jid name groups subsc ask} {
+    variable names
+
+    if {$subsc == "remove"} return
+
+    if {[info exists names($xlib,$jid)]} {
+	if {[roster::itemconfig $xlib $jid -name] == ""} {
+	    roster::itemconfig $xlib $jid -name $names($xlib,$jid)
+	    roster::send_item $xlib $jid
+	}
+	unset names($xlib,$jid)
+    }
+}
+
+hook::add roster_push_hook \
+	  [namespace current]::nick::set_received_name 20
+
+###############################################################################
+



More information about the Tkabber-dev mailing list