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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Dec 22 10:35:18 MSK 2006


Author: sergei
Date: 2006-12-22 10:35:15 +0300 (Fri, 22 Dec 2006)
New Revision: 832

Added:
   trunk/tkabber/plugins/roster/fetch_nicknames.tcl
Modified:
   trunk/tkabber/ChangeLog
Log:
	* plugins/roster/fetch_nicknames.tcl: Added plugin, which
	  automatically fetches user nickname from his/her vCard and
	  makes it roster label. For services (e.g. ICQ-transport) it
	  fetches nicknames for all service users.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-12-17 16:23:30 UTC (rev 831)
+++ trunk/tkabber/ChangeLog	2006-12-22 07:35:15 UTC (rev 832)
@@ -1,3 +1,10 @@
+2006-12-22  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/roster/fetch_nicknames.tcl: Added plugin, which
+	  automatically fetches user nickname from his/her vCard and
+	  makes it roster label. For services (e.g. ICQ-transport) it
+	  fetches nicknames for all service users.
+
 2006-12-16  Sergei Golovan  <sgolovan at nes.ru>
 
 	* msgs/ru.msg: Bugfix.

Added: trunk/tkabber/plugins/roster/fetch_nicknames.tcl
===================================================================
--- trunk/tkabber/plugins/roster/fetch_nicknames.tcl	                        (rev 0)
+++ trunk/tkabber/plugins/roster/fetch_nicknames.tcl	2006-12-22 07:35:15 UTC (rev 832)
@@ -0,0 +1,59 @@
+# $Id$
+# Fetch roster item nickname(s) from vCard and set roster label(s)
+
+namespace eval fetch_nickname {}
+
+proc fetch_nickname::service_request {connid service} {
+    foreach jid [::roster::get_jids $connid] {
+	if {[node_from_server $jid] == [node_from_server $service]} {
+	    user_request $connid $jid
+	}
+    }
+}
+
+proc fetch_nickname::user_request {connid jid} {
+    jlib::send_iq get \
+	[jlib::wrapper:createtag vCard \
+	     -vars [list xmlns vcard-temp]] \
+	-to $jid \
+	-connection $connid \
+	-command [list [namespace current]::parse_result $connid $jid]
+}
+
+proc fetch_nickname::parse_result {connid jid res child} {
+    if {$res != "OK"} return
+
+    jlib::wrapper:splitxml $child tag vars isempty chdata children
+
+    foreach item $children {
+	userinfo::parse_vcard_item $jid $item
+    }
+
+    if {[info exists ::userinfo::userinfo(nickname,$jid)] && \
+	    ![cequal $::userinfo::userinfo(nickname,$jid) ""]} {
+	roster::itemconfig $connid $jid \
+			   -name $::userinfo::userinfo(nickname,$jid)
+	roster::send_item $connid $jid
+    }
+}
+
+proc fetch_nickname::add_user_menu {m connid jid} {
+    set rjid [roster::find_jid $connid $jid]
+    $m add command -label [::msgcat::mc "Fetch nickname"] \
+	-command [list [namespace current]::user_request $connid $rjid]
+}
+
+hook::add chat_create_user_menu_hook \
+    [namespace current]::fetch_nickname::add_user_menu 73
+hook::add roster_jid_popup_menu_hook \
+    [namespace current]::fetch_nickname::add_user_menu 73
+
+proc fetch_nickname::add_service_menu {m connid jid} {
+    set rjid [roster::find_jid $connid $jid]
+    $m add command -label [::msgcat::mc "Fetch user nicknames"] \
+	-command [list [namespace current]::service_request $connid $rjid]
+}
+
+hook::add roster_service_popup_menu_hook \
+    [namespace current]::itemedit::prefs_user_menu 73
+


Property changes on: trunk/tkabber/plugins/roster/fetch_nicknames.tcl
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native



More information about the Tkabber-dev mailing list