[Tkabber-dev] r835 - in trunk/tkabber: . ifacetk msgs plugins/chat

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Dec 24 23:37:30 MSK 2006


Author: sergei
Date: 2006-12-24 23:37:26 +0300 (Sun, 24 Dec 2006)
New Revision: 835

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/msgs/ru.msg
   trunk/tkabber/muc.tcl
   trunk/tkabber/plugins/chat/draw_server_message.tcl
   trunk/tkabber/presence.tcl
   trunk/tkabber/roster.tcl
Log:
	* chats.tcl, ifacetk/iface.tcl, msgs/ru.msg, muc.tcl,
	  plugins/chat/draw_server_message.tcl, presence.tcl, roster.tcl:
	  Added chat messages on changing user status. These messages are off
	  by default.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/ChangeLog	2006-12-24 20:37:26 UTC (rev 835)
@@ -15,6 +15,11 @@
 	  chats and headlines during Tkabber exit. Separated opening headlines
 	  window from putting messages to it.
 
+	* chats.tcl, ifacetk/iface.tcl, msgs/ru.msg, muc.tcl,
+	  plugins/chat/draw_server_message.tcl, presence.tcl, roster.tcl:
+	  Added chat messages on changing user status. These messages are off
+	  by default.
+
 2006-12-22  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/roster/fetch_nicknames.tcl: Added plugin, which

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/chats.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -30,6 +30,10 @@
 	-type radio -group Chat \
 	-values [list normal [::msgcat::mc "Normal"] \
 		      chat [string trim [::msgcat::mc "Chat "]]]
+    custom::defvar options(gen_status_change_msgs) 0 \
+	[::msgcat::mc "Generate chat messages when room occupant or chat peer\
+	    changes his/her status and/or status message"] \
+	-type boolean -group Chat
 
     custom::defvar open_chat_list {} [::msgcat::mc "List of users for chat."] \
 	    -group Hidden
@@ -849,6 +853,7 @@
     global grouproster
     variable chats
     variable opened
+    variable options
     global statusdesc
 
     switch -- $type {
@@ -867,7 +872,6 @@
 
     set group [node_and_server_from_jid $jid]
     set chatid [chatid $connid $group]
-    set nick [get_nick $connid $jid groupchat]
 
     if {[info exists opened($chatid)]} {
 	if {[is_groupchat $chatid]} {
@@ -875,6 +879,7 @@
 	    if {[resource_from_jid $jid] == ""} {
 		return
 	    }
+	    set nick [get_nick $connid $jid groupchat]
 	    if {[cequal $status unavailable] || [cequal $status error]} {
 		if {$status == "error" && [is_our_jid $chatid $jid]} {
 		    add_message $chatid $group error \
@@ -914,6 +919,9 @@
 
 		    muc::process_available $chatid $nick
 		    hook::run chat_user_enter $chatid $nick
+		    muc::report_available $chatid $nick 1
+		} else {
+		    muc::report_available $chatid $nick 0
 		}
 		set grouproster(status,$chatid,$jid) $status
 		ifacetk::roster::changeicon $userswin $jid roster/user/$status
@@ -923,6 +931,20 @@
 	}
     }
 
+    # This case traces both chat and private groupchat conversations:
+    if {$options(gen_status_change_msgs)} {
+	set chatid [chatid $connid $jid]
+	if {[info exists opened($chatid)]} {
+	    set msg [get_nick $connid $jid chat]
+	    append msg " " [::get_long_status_desc [::get_user_status $connid $jid]]
+	    set desc [::get_user_status_desc $connid $jid]
+	    if {$desc != {}} {
+		append msg " ($desc)"
+	    }
+	    ::chat::add_message $chatid synthetic chat $msg {}
+	}
+    }
+
     set cw [winid [chatid $connid $jid]]
 
     if {[winfo exists $cw.status.icon]} {
@@ -1349,3 +1371,4 @@
 
 #############################################################################
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/ifacetk/iface.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -298,7 +298,7 @@
 		  [list cascad [::msgcat::mc "Chats"] {} chats $ifacetk::options(show_tearoffs) \
 		   [list \
 		    [list checkbutton [::msgcat::mc "Generate event messages"] {} {} {} \
-			 -variable muc::options(gen_events)] \
+			 -variable muc::options(gen_enter_exit_msgs)] \
 		    [list checkbutton [::msgcat::mc "Smart autoscroll"] {} {} {} \
 			 -variable chat::options(smart_scroll)] \
 		    [list checkbutton [::msgcat::mc "Stop autoscroll"] {} {} {} \

Modified: trunk/tkabber/msgs/ru.msg
===================================================================
--- trunk/tkabber/msgs/ru.msg	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/msgs/ru.msg	2006-12-24 20:37:26 UTC (rev 835)
@@ -55,6 +55,7 @@
     "Разрешить механизмы аутентификации, использующие открытый текст (при этом пароль передается незашифрованным)."
 ::msgcat::mcset ru "All unread messages was forwarded to %s." "Все непрочитанные сообщения были пересланы %s."
 ::msgcat::mcset ru "An error occured when searching in %s\n\n%s" "Возникла ошибка при поиске в %s\n\n%s"
+::msgcat::mcset ru "and" "и"
 ::msgcat::mcset ru "Announce" "Объявление"
 ::msgcat::mcset ru "Application Error" "Ошибка приложения"
 ::msgcat::mcset ru "Are you sure to remove group '%s' from roster? \n(Users which are in this group only, will be in undefined group.)" \
@@ -1023,18 +1024,18 @@
     "Настройка подсистемы оформления текста, которая используется для вывода сообщений и протоколов разговоров."
 ::msgcat::mcset ru "%s: %s/%s, Description: %s, Version: %s\nNumber of children: %s" \
     "%s: %s/%s, Описание: %s, Версия: %s\nЧисло ветвей: %s"
-::msgcat::mcset ru "%s is available" "%s доступен для разговора"
-::msgcat::mcset ru "%s is free to chat" "%s свободен для разговора"
-::msgcat::mcset ru "%s is away" "%s отошёл от компьютера"
-::msgcat::mcset ru "%s is extended away" "%s давно отошёл от компьютера"
-::msgcat::mcset ru "%s doesn't want to be disturbed" "%s не хочет, чтобы его беспокоили"
-::msgcat::mcset ru "%s is invisible" "%s невидимый"
+::msgcat::mcset ru "is available" "доступен для разговора"
+::msgcat::mcset ru "is free to chat" "свободен для разговора"
+::msgcat::mcset ru "is away" "отошёл от компьютера"
+::msgcat::mcset ru "is extended away" "давно отошёл от компьютера"
+::msgcat::mcset ru "doesn't want to be disturbed" "не хочет, чтобы его беспокоили"
+::msgcat::mcset ru "is invisible" "невидим"
 ::msgcat::mcset ru "%s is paused a reply" "%s остановился, набирая ответ"
-::msgcat::mcset ru "%s is unavailable" "%s недоступен для разговора"
+::msgcat::mcset ru "is unavailable" "недоступен для разговора"
 ::msgcat::mcset ru "%s has activated chat window" "%s активировал окно разговора"
 ::msgcat::mcset ru "%s has inactivated chat window" "%s деактивировал окно разговора"
 ::msgcat::mcset ru "%s has gone chat window" "%s закрыл окно разговора"
-::msgcat::mcset ru "%s has become available" "%s вошёл(а) в комнату"
+::msgcat::mcset ru "%s has entered" "%s вошёл(а) в комнату"
 ::msgcat::mcset ru "%s has been banned" "%s запретили входить в комнату"
 ::msgcat::mcset ru "%s has been kicked" "%s выгнали из комнаты"
 ::msgcat::mcset ru "%s has been kicked because of membership loss" "%s выгнали из комнаты в результате потери членства"

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/muc.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -6,9 +6,9 @@
 
 namespace eval muc {
     set winid 0
-    custom::defvar options(gen_events) 1 \
-	[::msgcat::mc "Generate event messages in MUC compatible\
-		       conference rooms."] \
+    custom::defvar options(gen_enter_exit_msgs) 1 \
+	[::msgcat::mc "Generate status messages when occupants\
+	    enter/exit MUC compatible conference rooms."] \
 	-type boolean -group Chat
     custom::defvar options(propose_configure) 0 \
 	[::msgcat::mc "Propose to configure newly created MUC room.\
@@ -944,7 +944,7 @@
 		if {$altjid != ""} {
 		    append msg [::msgcat::mc "\nAlternative venue: %s" $altjid]
 		}
-		if {$options(gen_events)} {
+		if {$options(gen_enter_exit_msgs)} {
 		    chat::add_message \
 			$chatid $group groupchat $msg {}
 		}
@@ -1002,7 +1002,7 @@
 			    append action ": $reason"
 			}
 
-			if {$options(gen_events)} {
+			if {$options(gen_enter_exit_msgs)} {
 			    variable ignore_unavailable $nick
 			    chat::add_message \
 				$chatid $group groupchat $action {}
@@ -1015,7 +1015,7 @@
 			    if {$nick == [get_our_groupchat_nick $chatid]} {
 				set_our_groupchat_nick $chatid $new_nick
 			    }
-			    if {$options(gen_events)} {
+			    if {$options(gen_enter_exit_msgs)} {
 				variable ignore_available   $new_nick
 				variable ignore_unavailable $nick
 
@@ -1038,8 +1038,6 @@
 
 
 proc muc::process_available {chatid nick} {
-    variable options
-    variable ignore_available
     variable pending_nicks
 
     set connid [chat::get_connid $chatid]
@@ -1050,18 +1048,6 @@
 	set_our_groupchat_nick $chatid $nick
 	unset pending_nicks($chatid)
     }
-    
-    if {[is_compatible $group] && $options(gen_events) && \
-	    (![info exists ignore_available] || \
-		 $ignore_available != $nick)} {
-	set real_jid [get_real_jid $connid $group/$nick]
-	if {$real_jid != ""} {
-	    set real_jid " ($real_jid)"
-	}
-	chat::add_message $chatid $group groupchat \
-	    [::msgcat::mc "%s has become available" $nick$real_jid] {}
-    }
-    catch { unset ignore_available }
 }
 
 
@@ -1071,7 +1057,7 @@
 
     set group [chat::get_jid $chatid]
 
-    if {[is_compatible $group] && $options(gen_events) && \
+    if {[is_compatible $group] && $options(gen_enter_exit_msgs) && \
 	    (![info exists ignore_unavailable] || \
 		 $ignore_unavailable != $nick)} {
 	set connid [chat::get_connid $chatid]
@@ -1087,6 +1073,51 @@
     catch { unset ignore_unavailable }
 }
 
+proc muc::report_available {chatid nick entered} {
+    variable ignore_available
+
+    set connid [::chat::get_connid $chatid]
+    set group [::chat::get_jid $chatid]
+
+    if {![is_compatible $group]} return
+
+    set jid $group/$nick
+
+    if {[::chat::is_our_jid $chatid $jid]} return
+
+    set msg ""
+
+    set report_entered [expr {$entered && $::muc::options(gen_enter_exit_msgs) \
+	&& (![info exists ignore_available] || $ignore_available != $nick)}]
+
+    if {$report_entered} {
+	set real_jid [get_real_jid $connid $jid]
+	if {$real_jid != ""} {
+	    set occupant "$nick ($real_jid)"
+	} else {
+	    set occupant $nick
+	}
+	set msg [format [::msgcat::mc "%s has entered"] $occupant]
+    }
+    catch { unset ignore_available }
+
+    if {$::chat::options(gen_status_change_msgs)} {
+	set status [::get_user_status $connid $jid]
+	if {$report_entered} {
+	    append msg " " [::msgcat::mc "and"] " "
+	} else {
+	    append msg $nick " "
+	}
+	append msg [::get_long_status_desc $status]
+	set desc [::get_user_status_desc $connid $jid]
+	if {$desc != {}} {
+	    append msg " ($desc)"
+	}
+    }
+
+    ::chat::add_message $chatid $group groupchat $msg {}
+}
+
 ###############################################################################
 
 proc muc::change_nick {chatid nick} {
@@ -1522,3 +1553,4 @@
 
 ###############################################################################
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/plugins/chat/draw_server_message.tcl
===================================================================
--- trunk/tkabber/plugins/chat/draw_server_message.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/plugins/chat/draw_server_message.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -2,7 +2,8 @@
 
 proc handle_server_message {chatid from type body x} {
     set jid [chat::get_jid $chatid]
-    if {[cequal $type groupchat] && [string equal $jid $from]} {
+    if {([cequal $type groupchat] && [string equal $jid $from]) \
+	|| ([cequal $type chat] && [cequal $from synthetic])} {
 	set chatw [chat::chat_win $chatid]
 
 	$chatw insert end --- server_lab " "
@@ -13,3 +14,5 @@
     }
 }
 hook::add draw_message_hook [namespace current]::handle_server_message 20
+
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/presence.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -2,6 +2,21 @@
 
 ###############################################################################
 
+array set long_statusdesc [list \
+    available   [::msgcat::mc "is available"] \
+    chat        [::msgcat::mc "is free to chat"] \
+    away        [::msgcat::mc "is away"] \
+    xa          [::msgcat::mc "is extended away"] \
+    dnd         [::msgcat::mc "doesn't want to be disturbed"] \
+    invisible   [::msgcat::mc "is invisible"] \
+    unavailable [::msgcat::mc "is unavailable"]]
+
+proc get_long_status_desc {status} {
+    set ::long_statusdesc($status)
+}
+
+###############################################################################
+
 proc client:presence {connid from type x args} {
     global presence
     global processed_presence
@@ -642,3 +657,4 @@
 
 ###############################################################################
 
+# vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/roster.tcl
===================================================================
--- trunk/tkabber/roster.tcl	2006-12-24 16:30:40 UTC (rev 834)
+++ trunk/tkabber/roster.tcl	2006-12-24 20:37:26 UTC (rev 835)
@@ -3,14 +3,6 @@
 namespace eval roster {
     variable undef_group_name [::msgcat::mc "Undefined"]
     variable chats_group_name [::msgcat::mc "Active Chats"]
-    array set long_statusdesc [list \
-	available   [::msgcat::mc "%s is available"] \
-	chat        [::msgcat::mc "%s is free to chat"] \
-	away        [::msgcat::mc "%s is away"] \
-	xa          [::msgcat::mc "%s is extended away"] \
-	dnd         [::msgcat::mc "%s doesn't want to be disturbed"] \
-	invisible   [::msgcat::mc "%s is invisible"] \
-	unavailable [::msgcat::mc "%s is unavailable"]]
 }
 
 proc roster::process_item {connid jid name groups subsc ask} {
@@ -229,7 +221,6 @@
 }
 
 proc roster::on_change_jid_presence {connid jid type x args} {
-    variable long_statusdesc
     variable roster
 
     switch -- $type {
@@ -248,8 +239,8 @@
 	if {$category == "user"} {
 	    set status [get_user_status $connid $rjid]
 	    set label [get_label $connid $rjid]
-	    if {![catch {set desc $long_statusdesc($status)}]} {
-		set_status [format $desc $label]
+	    if {![catch {set desc [::get_long_status_desc $status]}]} {
+		set_status [format "%s $desc" $label]
 	    }
 	    hook::run on_change_user_presence_hook $label $status
 	}
@@ -713,3 +704,4 @@
 
 ###############################################################################
 
+# vim:ts=8:sw=4:sts=4:noet



More information about the Tkabber-dev mailing list