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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Mar 31 09:16:12 MSD 2010


Author: bigote
Date: 2010-03-31 09:16:12 +0400 (Wed, 31 Mar 2010)
New Revision: 328

Modified:
   trunk/plugins/bldjid/ChangeLog
   trunk/plugins/bldjid/bldjid.tcl
Log:
Added version hash logging.
TODO: Add possibility to search by it.


Modified: trunk/plugins/bldjid/ChangeLog
===================================================================
--- trunk/plugins/bldjid/ChangeLog	2010-03-30 23:56:16 UTC (rev 327)
+++ trunk/plugins/bldjid/ChangeLog	2010-03-31 05:16:12 UTC (rev 328)
@@ -1,5 +1,18 @@
 2010-03-31  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
 
+--- Version 0.9.10 of the plugin.
+
+--- Files modified:
+    bldjid.tcl, ChangeLog.
+
+--- Changes:
+	Added version hash logging.
+
+--- TODO:
+	Add possibility to search by it.
+
+2010-03-31  Serge Yudin  <xmpp:bigote at jabber.ru> <mailto:bigote at gmail.com>
+
 --- Version 0.9.9.3 of the plugin.
 
 --- Files modified:

Modified: trunk/plugins/bldjid/bldjid.tcl
===================================================================
--- trunk/plugins/bldjid/bldjid.tcl	2010-03-30 23:56:16 UTC (rev 327)
+++ trunk/plugins/bldjid/bldjid.tcl	2010-03-31 05:16:12 UTC (rev 328)
@@ -1,4 +1,4 @@
-# "Bldjid" plugin for Tkabber. 2010-03-28 v. 0.9.9.3
+# "Bldjid" plugin for Tkabber. 2010-03-31 v. 0.9.10
 # Written by Serge Yudin xmpp:bigote at jabber.ru
 # See README or README.ru file for usage.
 
@@ -104,6 +104,7 @@
 # A variable where the last query result is stored.
 	variable user_list
 	variable watched_jids
+	variable jidver
 # An array where all user entrances are stored.
 	global jids_by_chats
 	variable ent_cntr 1
@@ -125,6 +126,7 @@
 proc bldjid::unload {} {
 	variable user_list
 	global jids_by_chats
+	variable jidver
 	variable ent_cntr
 	event delete <<ToggleMonitor>> <Control-m>
 
@@ -145,6 +147,7 @@
 	catch {unset jids_by_chats}
 	catch {unset ver_os}
 	catch {unset watched_jids}
+	catch {unset jidver}
 
 	foreach chatid [chat::opened] {
 		clear_monitor $chatid
@@ -172,6 +175,7 @@
 	variable ent_cntr
 	variable watched_jids
 	global jids_by_chats
+	variable jidver
 	variable options
 	if {!$options(enable_jids_gathering)} {
 		return
@@ -233,6 +237,11 @@
 			} else {
 				set role_aff ""
 			}
+			if {[info exists jidver($nick,$chatid)]} {
+				set ver_hash $jidver($nick,$chatid)
+			} else {
+				set ver_hash ""
+			}
 			if {$options(send_chat_messages) && $options(verbosity_level) == "min"} {
 				set occupant "$nick ($real_jid)"
 				set msg [::msgcat::mc "%s has entered" $occupant]
@@ -241,25 +250,27 @@
 			if {!$options(log_ver_os)} {
 				set ver_os ""
 				lappend jids_by_chats($group) \
-				[list $ts $nick $real_jid $role_aff $ver_os]
+				[list $ts $nick $real_jid $role_aff $ver_os $ver_hash]
 				if {$options(log_file) != ""} {
-					set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$real_jid\t$role_aff\t$ver_os"
+					set msg4log \
+					"$ent_cntr\t$ts\t$group\t$nick\t$real_jid\t$role_aff\t$ver_os\t$ver_hash"
 					[namespace current]::log_msg $msg4log
 					incr ent_cntr
 				}
 			} else {
 				set ver_os "Timeout"
 				lappend jids_by_chats($group) \
-				[list $ts $nick $real_jid $role_aff $ver_os]
+				[list $ts $nick $real_jid $role_aff $ver_os $ver_hash]
 				if {[[namespace current]::is_any_integer $options(ver_timeout)]} {
 					set vto [expr $options(ver_timeout) * 1000]
 				} else {
 					set vto 120000
 				}
 				set pid [after $vto \
-				[namespace current]::process_ver [list $nick $ts $group $real_jid $role_aff]]
+				[namespace current]::process_ver \
+				[list $nick $ts $group $real_jid $role_aff $ver_hash]]
 				[namespace current]::request_iq \
-				$xlib $chatid $group $nick $ts $real_jid $role_aff $pid
+				$xlib $chatid $group $nick $ts $real_jid $role_aff $ver_hash $pid
 			}
 		}
 	}
@@ -1025,14 +1036,16 @@
 }
 
 ### Thanks to Alexey Smirnov <alexey.smirnov at gmx.com>
-proc bldjid::extract_user {msg tsVar nickVar jidVar r_affVar v_osVar} {
-	upvar 1 $tsVar timestamp $nickVar nick $jidVar jid $r_affVar r_aff $v_osVar v_os
+proc bldjid::extract_user {msg tsVar nickVar jidVar r_affVar v_osVar v_hashVar} {
+	upvar 1 $tsVar timestamp $nickVar nick $jidVar jid \
+	$r_affVar r_aff $v_osVar v_os $v_hashVar v_h
 
 	set timestamp [lindex $msg 0]
 	set nick      [lindex $msg 1]
 	set jid       [lindex $msg 2]
 	set r_aff     [lindex $msg 3]
 	set v_os      [lindex $msg 4]
+	set v_h       [lindex $msg 5]
 
 	return
 }
@@ -1041,26 +1054,31 @@
 proc bldjid::format_msg {msg n} {
 	variable options
 	set s $options(custom_separator)
-	[namespace current]::extract_user $msg timestamp nick jid r_aff v_os
+	[namespace current]::extract_user $msg timestamp nick jid r_aff v_os v_h
 	if {$jid == ""} {
 		set jid "*NO JID*"
 	}
-	if {[llength $msg] == 5} {
+	if {[llength $msg] == 6} {
 		set myroom ""
 	} else {
-		set myroom " $s [lindex $msg 5]"
+		set myroom " $s [lindex $msg 6]"
 	}
 	if {$options(log_role_aff)} {
 		set myroleaff " $s $r_aff"
 	} else {
 		set myroleaff ""
 	}
+	if {$v_h != ""} {
+		set myvhash " $s $v_h"
+	} else {
+		set myvhash ""
+	}
 	if {$options(log_ver_os)} {
 		set myvos " $s $v_os"
 	} else {
 		set myvos ""
 	}
-		return "\n$n:\t$timestamp $s $nick $s $jid$myroleaff$myvos$myroom"
+		return "\n$n:\t$timestamp $s $nick $s $jid$myroleaff$myvos$myvhash$myroom"
 }
 
 proc bldjid::prepare_user_list {grpjds par} {
@@ -1259,10 +1277,10 @@
     close $fd
 	set lines [split $data \n]
 # Log format
-#	set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\t$ver_os"
+#	set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\t$ver_os\t$ver_hash"
 # jids_by_chats format
 #	lappend jids_by_chats($group) \
-#	[list $ts $nick $rjid $role_aff $ver_os]
+#	[list $ts $nick $rjid $role_aff $ver_os $ver_hash]
 	foreach line $lines {
 		set e [split $line \t]
 		set ts [lindex $e 1]
@@ -1274,25 +1292,30 @@
 		} else {
 			set r_aff ""
 		}
-		if {[llength $e] == 7} {
-			set v_os [lindex $e 6]
+		if {[llength $e] >= 7} {
+			set v_h [lindex $e 6]
 		} else {
+			set v_h ""
+		}
+		if {[llength $e] == 8} {
+			set v_os [lindex $e 7]
+		} else {
 			set v_os ""
 		}
-		lappend jbc_log($grp) [list $ts $nick $rjid $r_aff $v_os]
+		lappend jbc_log($grp) [list $ts $nick $rjid $r_aff $v_h $v_os]
 	}
 }
 
-proc bldjid::request_iq {xlib chatid group nick ts real_jid role_aff pid} {
+proc bldjid::request_iq {xlib chatid group nick ts real_jid role_aff ver_hash pid} {
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create query \
 	-xmlns jabber:iq:version] \
 	-to $group/$nick \
 	-command [list [namespace current]::parse_info_iqversion \
-		$chatid $group $nick $ts $real_jid $role_aff $pid]
+		$chatid $group $nick $ts $real_jid $role_aff $ver_hash $pid]
 }
 
-proc bldjid::parse_info_iqversion {chatid group nick ts rjid role_aff pid res child} {
+proc bldjid::parse_info_iqversion {chatid group nick ts rjid role_aff ver_hash pid res child} {
 	variable ent_cntr
 	variable options
 	global jids_by_chats
@@ -1325,7 +1348,8 @@
 		 	set val [lreplace $val 4 4 $ver_os]
 			set jids_by_chats($group) [lreplace $jids_by_chats($group) $i $i $val]
 			if {$options(log_file) != ""} {
-				set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\t$ver_os"
+				set msg4log \
+				"$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\t$ver_os\t$ver_hash"
 				[namespace current]::log_msg $msg4log
 				incr ent_cntr
 			}
@@ -1336,7 +1360,7 @@
 	}
 }
 
-proc bldjid::process_ver {nick ts group rjid role_aff} {
+proc bldjid::process_ver {nick ts group rjid role_aff ver_hash} {
 	variable ent_cntr
 	variable options
 	global jids_by_chats
@@ -1347,7 +1371,7 @@
 	foreach val $jids_by_chats($group) {
 		if {[string match "*$ts*" $val] && [string match *$nick* $val] \
 		 && [string match *Timeout* $val]} {
-			set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\tTimeout"
+			set msg4log "$ent_cntr\t$ts\t$group\t$nick\t$rjid\t$role_aff\tTimeout\t$ver_hash"
 			[namespace current]::log_msg $msg4log
 			incr ent_cntr
 			break
@@ -1359,21 +1383,16 @@
 # Taken from Clienticons plugin, thanks to Jet <megaxbit at xmpp.ru>!
 proc bldjid::caps_collector {xlib jid type x args} {
 	variable jidver
-	foreach xdata $x {
-		if {[::xmpp::xml::getAttr $xdata c] == "http://jabber.org/protocol/caps"} {
-			::xmpp::xml::split $xdata tag xmlns attrs cdata subels
-			set jidver($jid) [::xmpp::xml::getAttr $attrs ver]
-			set jidnodes($jid) [::xmpp::xml::getAttr $attrs node]
-[namespace current]::save_jidvers_to_file $jid $jidver($jid) $jidnodes($jid)
-puts "jidver: $jid -- $jidnodes($jid) -- $jidver($jid)"
-			return
+	set group [::xmpp::jid::stripResource $jid]
+	set chatid [chat::chatid $xlib $group]
+	set nick [::xmpp::jid::resource $jid]
+	if {[chat::is_groupchat $chatid]} {
+		foreach xdata $x {
+			if {[::xmpp::xml::getAttr $xdata c] == "http://jabber.org/protocol/caps"} {
+				::xmpp::xml::split $xdata tag xmlns attrs cdata subels
+				set jidver($nick,$chatid) [::xmpp::xml::getAttr $attrs ver]
+				return
+			}
 		}
 	}
 }
-
-proc bldjid::save_jidvers_to_file {jid ver node} {
-	set filename "$::configdir/bldjidver1.txt"
-	set f [open $filename a+]
-	puts $f "\n[clock format [clock seconds] -format {%Y-%m-%d_%H:%M:%S}]\tjid: $jid\tnode: $node\tver: $ver"
-	close $f
-}



More information about the Tkabber-dev mailing list