[Tkabber-dev] r903 - in trunk/tkabber: . plugins/chat plugins/general plugins/richtext

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Feb 7 22:31:35 MSK 2007


Author: sergei
Date: 2007-02-07 22:31:31 +0300 (Wed, 07 Feb 2007)
New Revision: 903

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/plugins/chat/draw_server_message.tcl
   trunk/tkabber/plugins/chat/log_on_open.tcl
   trunk/tkabber/plugins/chat/logger.tcl
   trunk/tkabber/plugins/chat/update_tab.tcl
   trunk/tkabber/plugins/general/sound.tcl
   trunk/tkabber/plugins/richtext/urls.tcl
Log:
	* chats.tcl: Add informational message to chat window if it is a chat
	  with groupchat user and she changes nickname (thanks to Konstantin
	  Khomoutov).

	* chats.tcl, plugins/chat/draw_server_message.tcl,
	  plugins/chat/log_on_open.tcl, plugins/chat/logger.tcl,
	  plugins/chat/update_tab.tcl, plugins/general/sound.tcl:
	  Replaced 'synthetic' JID in genersted messages by empty JID to
	  make sure it cannot be a real JID (thanks to Konstantin Khomoutov).

	* plugins/richtext/urls.tcl: Fixed duplicate URL processing in case of
	  nonstandard URL's (thanks to Konstantin Khomoutov).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/ChangeLog	2007-02-07 19:31:31 UTC (rev 903)
@@ -6,6 +6,19 @@
 	* plugins/si/socks5.tcl: Fixed bug with error on logout if there are
 	  pending IQ requests to SOCKS5 capable proxy.
 
+	* chats.tcl: Add informational message to chat window if it is a chat
+	  with groupchat user and she changes nickname (thanks to Konstantin
+	  Khomoutov).
+
+	* chats.tcl, plugins/chat/draw_server_message.tcl,
+	  plugins/chat/log_on_open.tcl, plugins/chat/logger.tcl,
+	  plugins/chat/update_tab.tcl, plugins/general/sound.tcl:
+	  Replaced 'synthetic' JID in genersted messages by empty JID to
+	  make sure it cannot be a real JID (thanks to Konstantin Khomoutov).
+
+	* plugins/richtext/urls.tcl: Fixed duplicate URL processing in case of
+	  nonstandard URL's (thanks to Konstantin Khomoutov).
+
 2007-02-01  Sergei Golovan  <sgolovan at nes.ru>
 
 	* utils.tcl: Optiimized jid_to_tag (thanks to Konstantin Khomoutov).

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/chats.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -125,7 +125,11 @@
 		set nick [roster::itemconfig $connid \
 			      [roster::find_jid $connid $jid] -name]
 		if {$nick == ""} {
-		    set nick [node_from_jid $jid]
+		    if {[node_from_jid $jid] != ""} {
+			set nick [node_from_jid $jid]
+		    } else {
+			set nick $jid
+		    }
 		}
 	    }
 	}
@@ -630,6 +634,37 @@
 
 ##############################################################################
 
+proc chat::trace_room_nickname_change {connid group nick new_nick} {
+    set from $group/$nick
+    set to $group/$new_nick
+    set chatid [::chat::chatid $connid $from]
+    set ix [lsearch -exact [::chat::opened] $chatid]
+    if {$ix < 0} return
+
+    set new_cid [::chat::chatid $connid $to]
+
+    set msg [format [::msgcat::mc \
+	"User %s has changed nick to %s."] \
+	$nick $new_nick]
+    ::chat::add_message $chatid "" chat $msg {}
+
+    set cw [chat_win $chatid]
+    $cw config -state normal
+    $cw delete {end - 1 char} ;# zap trailing newline
+    $cw insert end " "
+    set tooltip [::msgcat::mc "Opens a new chat conversation\
+	with the new nick of the room occupant"]
+    ::plugins::urls::render_url $cw url $tooltip {} \
+	-title [::msgcat::mc "Start chat with the new nick"] \
+	-command [list [namespace current]::open_window $new_cid chat]
+    $cw insert end \n
+    $cw config -state disabled
+}
+
+hook::add room_nickname_changed_hook chat::trace_room_nickname_change
+
+##############################################################################
+
 proc chat::check_connid {connid chatid} {
     if {[get_connid $chatid] == $connid} {
 	return 1
@@ -977,7 +1012,7 @@
 	    if {$desc != {}} {
 		append msg " ($desc)"
 	    }
-	    ::chat::add_message $chatid synthetic chat $msg {}
+	    ::chat::add_message $chatid "" chat $msg {}
 	}
     }
 

Modified: trunk/tkabber/plugins/chat/draw_server_message.tcl
===================================================================
--- trunk/tkabber/plugins/chat/draw_server_message.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/chat/draw_server_message.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -3,7 +3,7 @@
 proc handle_server_message {chatid from type body x} {
     set jid [chat::get_jid $chatid]
     if {([cequal $type groupchat] && [string equal $jid $from]) \
-	|| ([cequal $type chat] && [cequal $from synthetic])} {
+	|| ([cequal $type chat] && $from == "")} {
 	set chatw [chat::chat_win $chatid]
 
 	$chatw insert end --- server_lab " "

Modified: trunk/tkabber/plugins/chat/log_on_open.tcl
===================================================================
--- trunk/tkabber/plugins/chat/log_on_open.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/chat/log_on_open.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -46,7 +46,10 @@
 				       stamp $date]]
 	}
 	if {[info exists tmp(jid)]} {
-	    if {(!$gc && [node_and_server_from_jid $tmp(jid)] != $bare_jid) || \
+	    if {$tmp(jid) == ""} {
+		# Synthesized message
+		set from ""
+	    } elseif {(!$gc && [node_and_server_from_jid $tmp(jid)] != $bare_jid) || \
 		 $gc && $tmp(jid) != $jid} {
 		set from [jlib::connection_jid $connid]
 	    } else {
@@ -67,3 +70,4 @@
 
 hook::add open_chat_post_hook [namespace current]::log_on_open::show 100
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/plugins/chat/logger.tcl
===================================================================
--- trunk/tkabber/plugins/chat/logger.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/chat/logger.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -346,17 +346,29 @@
 	    set seconds [clock scan $tmp(timestamp) -gmt 1]
 	    $l insert end [clock format $seconds -format {[%Y-%m-%d %X]}]
 	}
-	if {[info exists tmp(nick)] && $tmp(nick) != ""} {
-	    if {[string equal $tmp(nick) $mynick]} {
+	if {[info exists tmp(jid)] && $tmp(jid) == ""} {
+	    # synthesized message
+	    $l insert end "---" server_lab
+	    set servertag server
+	} elseif {([info exists tmp(nick)] && $tmp(nick) != "") || \
+			([info exists tmp(jid)] && $tmp(jid) != "")} {
+	    if {[info exists tmp(nick)] && $tmp(nick) != ""} {
+		set nick $tmp(nick)
+	    } elseif {[node_from_jid $tmp(jid)] != ""} {
+		set nick [node_from_jid $tmp(jid)]
+	    } else {
+		set nick $tmp(jid)
+	    }
+	    if {[string equal $nick $mynick]} {
 		set tag me
 	    } else {
 		set tag they
 	    }
 	    if {[info exists tmp(body)] && [regsub {^/me } $tmp(body) {} body]} {
-		$l insert end "*$tmp(nick) $body" $tag
+		$l insert end "*$nick $body" $tag
 		unset tmp(body)
 	    } else {
-		$l insert end "<$tmp(nick)>" $tag
+		$l insert end "<$nick>" $tag
 	    }
 	    set servertag ""
 	} else {
@@ -825,3 +837,4 @@
 
 #############################################################################
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/plugins/chat/update_tab.tcl
===================================================================
--- trunk/tkabber/plugins/chat/update_tab.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/chat/update_tab.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -46,7 +46,8 @@
 	}
 	chat -
 	default {
-	    if {$from == "synthetic"} {
+	    if {$from == ""} {
+		# synthesized message
 		tab_set_updated $cw 1 server
 	    } else {
 		tab_set_updated $cw 1 mesg_to_user
@@ -55,3 +56,4 @@
     }
 }
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/plugins/general/sound.tcl
===================================================================
--- trunk/tkabber/plugins/general/sound.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/general/sound.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -243,6 +243,8 @@
 
 	    if {[chat::is_our_jid $chatid $from]} {
 		play $sounds(chat_my_message)
+	    } elseif {$from == ""} {
+		play $sounds(groupchat_server_message)
 	    } else {
 		play $sounds(chat_their_message) -1
 	    }

Modified: trunk/tkabber/plugins/richtext/urls.tcl
===================================================================
--- trunk/tkabber/plugins/richtext/urls.tcl	2007-02-07 18:36:47 UTC (rev 902)
+++ trunk/tkabber/plugins/richtext/urls.tcl	2007-02-07 19:31:31 UTC (rev 903)
@@ -177,7 +177,7 @@
 	      $w $privtag $options(activeforeground) $options(cursor)]
     $w tag bind $privtag <Any-Leave> \
 	[list ::richtext::highlighttext \
-	      $w $privtag $options(foreground) xterm]
+	      $w $privtag $options(foreground) [$w cget -cursor]]
 
     if {$show_hints} {
 	$w tag bind $privtag <Any-Enter> \
@@ -188,6 +188,10 @@
 	    +[list [namespace current]::balloon $w $privtag leave %x %y %X %Y]
     }
 
+    # Default URL action:
+    config_url $w $privtag \
+	-command [list [namespace current]::browse_url %W %x %y]
+
     eval {config_url $w $privtag} $args
 
     incr urlid
@@ -299,8 +303,6 @@
     set options(activeforeground) [option get $w urlactiveforeground Text]
     set options(cursor)           [option get $w urlcursor           Text]
 
-    config_url $w url -command [list [namespace current]::browse_url %W %x %y]
-
     # "uri" -- tag for "hidden" URLs (presented as their alt. text):
     $w tag configure uri -elide 1
 }



More information about the Tkabber-dev mailing list