[Tkabber-dev] r1503 - in trunk/tkabber: . ifacetk jabberlib plugins/general sounds/default

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Sep 25 23:08:56 MSD 2008


Author: sergei
Date: 2008-09-25 23:08:54 +0400 (Thu, 25 Sep 2008)
New Revision: 1503

Added:
   trunk/tkabber/sounds/default/chat_my_message.wav
   trunk/tkabber/sounds/default/disconnected.wav
   trunk/tkabber/sounds/default/groupchat_my_message.wav
Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/jabberlib/jabberlib.tcl
   trunk/tkabber/login.tcl
   trunk/tkabber/plugins/general/sound.tcl
   trunk/tkabber/sounds/default/chat_their_message.wav
   trunk/tkabber/sounds/default/connected.wav
   trunk/tkabber/sounds/default/groupchat_server_message.wav
   trunk/tkabber/sounds/default/groupchat_their_message.wav
   trunk/tkabber/sounds/default/groupchat_their_message_to_me.wav
   trunk/tkabber/sounds/default/presence_available.wav
   trunk/tkabber/sounds/default/presence_unavailable.wav
Log:
	* ifacetk/iface.tcl: A bit optimized running of map_window_hook.

	* chats.tcl: Added new hook draw_message_post_hook. It is necessary
	  because procedures in a usual draw_message_hook often return stop,
	  so it's impossible to add a procedure to the very end of the hook
	  and be sure it will be executed (thanks to Konstantin Khomoutov).

	* jabberlib/jabberlib.tcl, login.tcl: Reworked forced disconnecting
	  from a server to make possible to use sound notification.

	* plugins/general/sound.tcl: Added sound notification for disconnect
	  and changed default sounds for own chat and groupchat messages.

	* sounds/default/*.wav: Replaced default sound theme by a new original
	  one (thanks to Serge Yudin).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/ChangeLog	2008-09-25 19:08:54 UTC (rev 1503)
@@ -1,3 +1,21 @@
+2008-09-25  Sergei Golovan  <sgolovan at nes.ru>
+
+	* ifacetk/iface.tcl: A bit optimized running of map_window_hook.
+
+	* chats.tcl: Added new hook draw_message_post_hook. It is necessary
+	  because procedures in a usual draw_message_hook often return stop,
+	  so it's impossible to add a procedure to the very end of the hook
+	  and be sure it will be executed (thanks to Konstantin Khomoutov).
+
+	* jabberlib/jabberlib.tcl, login.tcl: Reworked forced disconnecting
+	  from a server to make possible to use sound notification.
+
+	* plugins/general/sound.tcl: Added sound notification for disconnect
+	  and changed default sounds for own chat and groupchat messages.
+
+	* sounds/default/*.wav: Replaced default sound theme by a new original
+	  one (thanks to Serge Yudin).
+
 2008-09-12  Sergei Golovan  <sgolovan at nes.ru>
 
 	* gpgme.tcl: Ported key info processing to GPG package where its

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/chats.tcl	2008-09-25 19:08:54 UTC (rev 1503)
@@ -877,6 +877,8 @@
 
 	$chatw configure -state disabled
     }
+
+    hook::run draw_message_post_hook $chatid $from $type $body $x
 }
 
 proc chat::add_open_to_user_menu_item {m connid jid} {

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/ifacetk/iface.tcl	2008-09-25 19:08:54 UTC (rev 1503)
@@ -986,7 +986,7 @@
 	}
     }
 
-    bind . <Map> [list hook::run map_window_hook %W]
+    bind . <Map> [list [namespace current]::map_dot %W]
 
     wm geometry . $geometry
 
@@ -994,6 +994,12 @@
     update idletasks
 }
 
+proc ifacetk::map_dot {w} {
+    if {$w != "."} return
+
+    hook::run map_window_hook $w
+}
+
 proc ifacetk::destroy_tab {page} {
     if {[.nb raise] != ""} {
 	eval destroy [pack slaves [.nb getframe $page]]

Modified: trunk/tkabber/jabberlib/jabberlib.tcl
===================================================================
--- trunk/tkabber/jabberlib/jabberlib.tcl	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/jabberlib/jabberlib.tcl	2008-09-25 19:08:54 UTC (rev 1503)
@@ -253,8 +253,6 @@
 	return -code error $sock
     }
 
-    lappend lib(connections) $connid
-
     set lib($connid,xmlns) $xmlns
     set lib($connid,password) $password
     set lib($connid,transport) $transport
@@ -314,6 +312,8 @@
 	lappend params -version "1.0"
     }
 
+    lappend lib(connections) $connid
+
     eval [list start_stream $server -connection $connid] $params
 
     return $connid
@@ -419,30 +419,29 @@
 
 ########################################################################
 
-proc jlib::disconnect {{connections {}}} {
+proc jlib::disconnect {connid} {
     variable lib
 
-    ::LOG "(jlib::disconnect) $connections"
+    ::LOG "(jlib::disconnect) $connid"
 
-    if {$connections == {}} {
-	set connections $lib(connections)
-    }
+    set idx [lsearch -exact $lib(connections) $connid]
+    if {$idx < 0} continue
 
-    foreach connid $connections {
-	set idx [lsearch -exact $lib(connections) $connid]
-	if {$idx < 0} continue
+    set lib(connections) [lreplace $lib(connections) $idx $idx]
 
-	finish_stream -connection $connid
+    if {!$lib($connid,disconnecting)} {
 	set lib($connid,disconnecting) 1
+
+	finish_stream -connection $connid
+
 	catch {
 	    transport::$lib($connid,transport)::disconnect $connid
 	    transport::$lib($connid,transport)::close $connid
 	}
-
-	set lib(connections) [lreplace $lib(connections) $idx $idx]
-	clear_vars $connid
     }
 
+    clear_vars $connid
+
     if {$lib(connections) == {}} {
 	clear_iqs
     }
@@ -450,6 +449,24 @@
 
 ######################################################################
 
+proc jlib::emergency_disconnect {connid} {
+    variable lib
+
+    ::LOG "(jlib::emergency_disconnect) $connid"
+
+    if {[lsearch -exact $lib(connections) $connid] < 0} return
+
+    set lib($connid,disconnecting) 1
+
+    catch {
+	transport::$lib($connid,transport)::close $connid
+    }
+
+    client $lib($connid,disconnect) $connid
+}
+
+######################################################################
+
 proc jlib::got_stream {connid vars} {
     variable lib
 
@@ -519,8 +536,6 @@
 	# Already disconnected
     }
 
-    transport::$lib($connid,transport)::close $connid
-
     if {!$lib($connid,disconnecting)} {
 	after idle [list [namespace current]::emergency_disconnect $connid]
     }
@@ -659,25 +674,6 @@
 
 ######################################################################
 
-proc jlib::emergency_disconnect {connid} {
-    variable lib
-
-    set idx [lsearch -exact $lib(connections) $connid]
-
-    if {$idx < 0} return
-
-    set lib(connections) [lreplace $lib(connections) $idx $idx]
-
-    client $lib($connid,disconnect) $connid
-
-    clear_vars $connid
-    if {$lib(connections) == {}} {
-	clear_iqs
-    }
-}
-
-######################################################################
-
 proc jlib::clear_vars {connid} {
     #
     # unset all the variables

Modified: trunk/tkabber/login.tcl
===================================================================
--- trunk/tkabber/login.tcl	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/login.tcl	2008-09-25 19:08:54 UTC (rev 1503)
@@ -471,23 +471,22 @@
     global reconnect_retries
     global login_after_id
 
+    debugmsg login "LOGOUT $connid"
+
     # TODO
     foreach user [array names login_after_id] {
 	after cancel $login_after_id($user)
 	unset login_after_id($user)
     }
 
-    hook::run predisconnected_hook $connid
-
-    jlib::disconnect $connid
     if {$connid == {}} {
-	roster::clean
+	foreach connid [jlib::connections] {
+	    disconnected $connid
+	}
     } else {
-	roster::clean_connection $connid
+	disconnected $connid
     }
 
-    disconnected $connid
-
     set reconnect_retries 0
 }
 
@@ -502,15 +501,6 @@
 
     debugmsg login "RECONNECT $connid"
 
-    hook::run predisconnected_hook $connid
-
-    jlib::disconnect $connid
-    roster::clean_connection $connid
-
-    if {[jlib::connections] == {}} {
-	set_status "Disconnected"
-    }
-
     disconnected $connid
 
     if {[incr reconnect_retries] <= 3} {
@@ -526,11 +516,19 @@
 proc disconnected {connid} {
     global curuserstatus userstatusdesc
 
+    hook::run predisconnected_hook $connid
+
+    jlib::disconnect $connid
+    roster::clean_connection $connid
+
     if {[jlib::connections] == {}} {
+	set_status "Disconnected"
+
 	set curuserstatus unavailable
 	set userstatusdesc [::msgcat::mc "Not logged in"]
 	hook::run change_our_presence_post_hook unavailable
     }
+
     hook::run disconnected_hook $connid
 }
 
@@ -575,7 +573,7 @@
 
 proc recv_register_result {connid logindata res args} {
     if {$res == "OK"} {
-	jlib::disconnect
+	jlib::disconnect $connid
 	login $logindata
     } else {
 	if {[winfo exists .auth_err$connid]} {

Modified: trunk/tkabber/plugins/general/sound.tcl
===================================================================
--- trunk/tkabber/plugins/general/sound.tcl	2008-09-13 09:37:16 UTC (rev 1502)
+++ trunk/tkabber/plugins/general/sound.tcl	2008-09-25 19:08:54 UTC (rev 1503)
@@ -52,6 +52,11 @@
 	[::msgcat::mc "Sound to play when connected to Jabber server."] \
 	-command [list [namespace current]::load_sound_file connected] \
 	-type file -group Sound
+    custom::defvar options(disconnected_sound) \
+	[fullpath sounds default disconnected.wav] \
+	[::msgcat::mc "Sound to play when disconnected from Jabber server."] \
+	-command [list [namespace current]::load_sound_file disconnected] \
+	-type file -group Sound
     custom::defvar options(presence_available_sound) \
 	[fullpath sounds default presence_available.wav] \
 	[::msgcat::mc "Sound to play when available presence is received."] \
@@ -63,7 +68,7 @@
 	-command [list [namespace current]::load_sound_file presence_unavailable] \
 	-type file -group Sound
     custom::defvar options(chat_my_message_sound) \
-	"" \
+	[fullpath sounds default chat_my_message.wav] \
 	[::msgcat::mc "Sound to play when sending personal chat message."] \
 	-command [list [namespace current]::load_sound_file chat_my_message] \
 	-type file -group Sound
@@ -78,7 +83,7 @@
 	-command [list [namespace current]::load_sound_file groupchat_server_message] \
 	-type file -group Sound
     custom::defvar options(groupchat_my_message_sound) \
-	"" \
+	[fullpath sounds default groupchat_my_message.wav] \
 	[::msgcat::mc "Sound to play when groupchat message from me is received."] \
 	-command [list [namespace current]::load_sound_file groupchat_my_message] \
 	-type file -group Sound
@@ -107,6 +112,7 @@
 	[namespace current]::presence_notify 100
     hook::add change_our_presence_post_hook [namespace current]::mute_setup 100
     hook::add connected_hook [namespace current]::connected_notify 100
+    hook::add predisconnected_hook [namespace current]::disconnected_notify 100
     hook::add postload_hook [namespace current]::sound_setup 100
     hook::add draw_message_hook [namespace current]::chat_message_notify 19
 }
@@ -284,7 +290,7 @@
     }
 }
 
-proc ::sound::connected_notify {args} {
+proc ::sound::connected_notify {connid} {
     variable options
     variable sounds
 
@@ -293,6 +299,23 @@
     play $sounds(connected) 1
 }
 
+proc ::sound::disconnected_notify {connid} {
+    variable options
+    variable sounds
+
+    if {[is_mute]} return
+
+    if {$connid == {}} {
+	if {[llength [jlib::connections]] > 0} {
+	    play $sounds(disconnected) 1
+	}
+    } else {
+	if {[lsearch -exact [jlib::connections] $connid] >= 0} {
+	    play $sounds(disconnected) 1
+	}
+    }
+}
+
 proc ::sound::is_mute {} {
     variable snack
     variable options

Added: trunk/tkabber/sounds/default/chat_my_message.wav
===================================================================
(Binary files differ)


Property changes on: trunk/tkabber/sounds/default/chat_my_message.wav
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/tkabber/sounds/default/chat_their_message.wav
===================================================================
(Binary files differ)

Modified: trunk/tkabber/sounds/default/connected.wav
===================================================================
(Binary files differ)

Added: trunk/tkabber/sounds/default/disconnected.wav
===================================================================
(Binary files differ)


Property changes on: trunk/tkabber/sounds/default/disconnected.wav
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/tkabber/sounds/default/groupchat_my_message.wav
===================================================================
(Binary files differ)


Property changes on: trunk/tkabber/sounds/default/groupchat_my_message.wav
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/tkabber/sounds/default/groupchat_server_message.wav
===================================================================
(Binary files differ)

Modified: trunk/tkabber/sounds/default/groupchat_their_message.wav
===================================================================
(Binary files differ)

Modified: trunk/tkabber/sounds/default/groupchat_their_message_to_me.wav
===================================================================
(Binary files differ)

Modified: trunk/tkabber/sounds/default/presence_available.wav
===================================================================
(Binary files differ)

Modified: trunk/tkabber/sounds/default/presence_unavailable.wav
===================================================================
(Binary files differ)



More information about the Tkabber-dev mailing list