[Tkabber-dev] r283 - trunk/plugins/bldjid

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Feb 4 06:29:31 MSK 2010


Author: bigote
Date: 2010-02-04 06:29:31 +0300 (Thu, 04 Feb 2010)
New Revision: 283

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/TODO
   trunk/plugins/bldjid/bldjid.tcl
Log:
Logging visitors' client version and OS works now.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2010-02-03 07:17:52 UTC (rev 282)
+++ trunk/plugins/bldjid/ChangeLog	2010-02-04 03:29:31 UTC (rev 283)
@@ -1,3 +1,13 @@
+2010-02-04  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
+--- Version 0.7 of the plugin.
+
+--- Files modified:
+    bldjid.tcl, TODO, ChangeLog
+
+--- Changes:
+	Logging visitors' client version and OS works now.
+
 2010-02-03  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
 --- Version 0.6.5 of the plugin.

Modified: trunk/plugins/bldjid/TODO
===================================================================
--- trunk/plugins/bldjid/TODO	2010-02-03 07:17:52 UTC (rev 282)
+++ trunk/plugins/bldjid/TODO	2010-02-04 03:29:31 UTC (rev 283)
@@ -18,8 +18,14 @@
 ---	It would be nice to be able to show messages about nick changing
 	and also about kicking and banning people.
 
-===	Add possibility to log client version
-	for better distinguishing of visitors.
+===	Since a possibility added to log client version, it would be cool
+	to use /visited command to filter out visitors by different parameters:
+	nick (already implemented), jid, role or affiliation, Client version, OS.
+---	Due to extreme length of Version/OS text it could be uncomfortable
+	to have it always displayed. I'd prefer to add an option that would allow
+	to turn displaying such information ON or OFF (it would be independent from
+	log_ver_os option, so a user could log Ver/OS info without displaying it,
+	still being able to enable displaying it at any time he or she needs).
 
 ===	Fix a bug with broken monitor window if editing window size is changed.
 

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2010-02-03 07:17:52 UTC (rev 282)
+++ trunk/plugins/bldjid/bldjid.tcl	2010-02-04 03:29:31 UTC (rev 283)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2010-02-03 v. 0.6.5
+# "Bldjid" plugin for Tkabber. 2010-02-04 v. 0.7
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README or README.ru file for usage.
 
@@ -99,7 +99,6 @@
 	variable user_list
 # An array where all user entrances are stored.
 	global jids_by_chats
-	variable ver_os
 	variable ent_cntr 1
 	event add <<ToggleMonitor>> <Control-m>
 
@@ -117,7 +116,6 @@
 proc bldjid::unload {} {
 	variable user_list
 	global jids_by_chats
-	variable ver_os
 	variable ent_cntr
 	event delete <<ToggleMonitor>> <Control-m>
 
@@ -160,9 +158,7 @@
 ## Adapted to bldjid's necessities by Serge Yudin
 proc bldjid::smart_enter_exit_message {chatid nick} {
 	global jids_by_chats
-	variable ver_os ""
 	variable options
-	variable ent_cntr
 	if {!$options(enable_jids_gathering)} {
 		return
 	}
@@ -180,9 +176,9 @@
 			if {$nick == ""} {
 				return
 			}
-			set ts [clock format [clock seconds] \
-			-format $::plugins::options(timestamp_format)]
 			set xlib [::chat::get_xlib $chatid]
+			set ts [clock format [clock seconds] \
+				-format $::plugins::options(timestamp_format)]
 			set real_jid [::muc::get_real_jid $xlib $group/$nick]
 			if {$options(strip_resource)} {
 				set real_jid [::xmpp::jid::stripResource $real_jid]
@@ -208,31 +204,13 @@
 			}
 			set role_aff [::muc::get_role $xlib $group/$nick]
 			append role_aff "/" [::muc::get_affiliation $xlib $group/$nick]
-
-#			[namespace current]::request_iq $xlib $chatid $group/$nick
-### TODO: Some smart mechanism of getting correct versions
-### after a great delay should be implemented.
-### Something like checking the array "ver_os" in a loop
-### until a certain jid appears.
 			if {$options(send_chat_messages) && $options(verbosity_level) == "min"} {
 				set occupant "$nick ($real_jid)"
 				set msg [::msgcat::mc "%s has entered" $occupant]
 				::chat::add_message $chatid $group groupchat $msg {}
 			}
-set ver_os "Version will be here"
-			if {$options(log_file) != ""} {
-                set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$real_jid\t$role_aff\t$ver_os"
-			    [namespace current]::log_msg $msg4log
-				incr ent_cntr
-			}
-			if {!$options(log_role_aff)} {
-				set role_aff ""
-			}
-			if {!$options(log_ver_os)} {
-				set ver_os ""
-			}
-			lappend jids_by_chats($group) \
-			[list $ts $nick $real_jid $role_aff $ver_os]
+			[namespace current]::request_iq \
+			$xlib $chatid $group $nick $ts $real_jid $role_aff
 		}
 	}
 }
@@ -909,33 +887,30 @@
     close $fd
 }
 
-proc bldjid::request_iq {xlib chatid jid} {
+proc bldjid::request_iq {xlib chatid group nick ts real_jid role_aff} {
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create query \
-		-xmlns jabber:iq:version] \
-	-to $jid \
-	-command [list [namespace current]::parse_info_iqversion $chatid $jid]
+	-xmlns jabber:iq:version] \
+	-to $group/$nick \
+	-command [list [namespace current]::parse_info_iqversion \
+		$chatid $group $nick $ts $real_jid $role_aff]
 }
 
-proc bldjid::parse_info_iqversion {chatid jid res child} {
-### TODO: This variable should be an array to save pairs FULL_JID/VER_OS.
-### Otherwise we won't know whom a particular version belongs to.
-	variable ver_os
-#    if {![winfo exists [chat::chat_win $chatid]]} {
-#		return
-#    }
-
-#    set rjid [::muc::whois $chatid $jid]
+proc bldjid::parse_info_iqversion {chatid group nick ts rjid role_aff res child} {
+	variable ent_cntr
+	variable options
+	global jids_by_chats
+    if {![winfo exists [chat::chat_win $chatid]]} {
+		return
+    }
+	set jid $group/$nick
     if {![cequal $res ok]} {
-		set ver_os "no info"
+		set ver_os "*NO VER/OS*"
     }
 
     ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    if {[string equal $xmlns jabber:iq:version]} {
-		userinfo::parse_iqversion_item $jid $subels
-    }
-
+	userinfo::parse_iqversion_item $jid $subels
     foreach {i j} [list clientname    [::msgcat::mc "Client:"] \
 		    clientversion [::msgcat::mc "Version:"] \
 		    os            [::msgcat::mc "OS:"]] {
@@ -944,4 +919,18 @@
 	    	append ver_os " $j $userinfo::userinfo($i,$jid)"
 		}
     }
+	set ver_os [string trim $ver_os]
+	if {$options(log_file) != ""} {
+		set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\t$ver_os"
+		[namespace current]::log_msg $msg4log
+		incr ent_cntr
+	}
+	if {!$options(log_role_aff)} {
+		set role_aff ""
+	}
+	if {!$options(log_ver_os)} {
+		set ver_os ""
+	}
+	lappend jids_by_chats($group) \
+	[list $ts $nick $rjid $role_aff $ver_os]
 }



More information about the Tkabber-dev mailing list