[Tkabber-dev] r1245 - in trunk/tkabber-plugins: . floatinglog

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Oct 6 15:36:58 MSD 2007


Author: sergei
Date: 2007-10-06 15:36:57 +0400 (Sat, 06 Oct 2007)
New Revision: 1245

Added:
   trunk/tkabber-plugins/floatinglog/
   trunk/tkabber-plugins/floatinglog/AUTHORS
   trunk/tkabber-plugins/floatinglog/ChangeLog
   trunk/tkabber-plugins/floatinglog/INSTALL
   trunk/tkabber-plugins/floatinglog/TODO
   trunk/tkabber-plugins/floatinglog/VERSION
   trunk/tkabber-plugins/floatinglog/floatinglog.tcl
   trunk/tkabber-plugins/floatinglog/license.terms
Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/Makefile
   trunk/tkabber-plugins/README
Log:
	* floatinglog/*, README, Makefile: Added new plugin which reports
	  about incoming messages in a floating log window (thanks to Ruslan
	  Rakhmanin).


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-10-06 07:53:04 UTC (rev 1244)
+++ trunk/tkabber-plugins/ChangeLog	2007-10-06 11:36:57 UTC (rev 1245)
@@ -3,6 +3,10 @@
 	* browser/browser.tcl: Replaced ::jlib::route by the first connection
 	  in cinnection list.
 
+	* floatinglog/*, README, Makefile: Added new plugin which reports
+	  about incoming messages in a floating log window (thanks to Ruslan
+	  Rakhmanin).
+
 2007-10-05  Sergei Golovan <sgolovan at nes.ru>
 
 	* README: Added missing descriptions.

Modified: trunk/tkabber-plugins/Makefile
===================================================================
--- trunk/tkabber-plugins/Makefile	2007-10-06 07:53:04 UTC (rev 1244)
+++ trunk/tkabber-plugins/Makefile	2007-10-06 11:36:57 UTC (rev 1245)
@@ -14,6 +14,7 @@
 	  cyrillize    \
 	  debug        \
 	  ejabberd     \
+	  floatinglog  \
 	  georoster    \
 	  gmail        \
 	  iconsets     \

Modified: trunk/tkabber-plugins/README
===================================================================
--- trunk/tkabber-plugins/README	2007-10-06 07:53:04 UTC (rev 1244)
+++ trunk/tkabber-plugins/README	2007-10-06 11:36:57 UTC (rev 1245)
@@ -54,6 +54,10 @@
 ejabberd
     Utility to check your Ejabberd Jabber server remotely.
 
+floatinglog
+    Plugin reports incoming messages, presence changes, status changes in a
+    separate floating window.
+
 georoster
     World map. It tries to position your contacts using the data on vcard.
     You can also drag and drop your contacts from the roster on their

Added: trunk/tkabber-plugins/floatinglog/AUTHORS
===================================================================
--- trunk/tkabber-plugins/floatinglog/AUTHORS	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/AUTHORS	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,2 @@
+Rakhmanin Ruslan <rakhmaninr at mail.ru>
+Thanks to Konstantin Khomoutov for is_delayed function.


Property changes on: trunk/tkabber-plugins/floatinglog/AUTHORS
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/ChangeLog
===================================================================
--- trunk/tkabber-plugins/floatinglog/ChangeLog	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/ChangeLog	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,54 @@
+Version 0.4
+
+2007-08-26  Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+	 * Double click on FloatingLog opens Tkabber window
+	 
+	 * You can off incoming message body show (it will show "Incoming message" string). 
+	   Option "show_message_body". Default is on.
+
+	 * New default scheme of incoming message view.
+	   You can use old (simple) scheme by checking "simple_show_scheme" option.
+
+	 * Some bags fixed
+
+Version 0.3.1
+
+2007-06-28  Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+	 * You can off FloatingLog in away, xa, dnd status 
+	 
+	 * You can choose if FloatingLog will show messages on active Tkabber window
+
+
+Version 0.3
+
+2007-06-28  Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+	 * Hide FloatingLog window on rigth button mouse click
+	 
+	 * Do not show messages on active Tkabber window
+
+	 * Use default colors from Tkabber for FloatingLog window
+
+
+Version 0.2
+
+2007-06-06  Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+	 * Do not show history messages from groupchat (on connecting to groupchat).
+	 
+	 * Do not show idle messages.
+
+	 * Options for on/off messages from chat, groupchat, other messages.
+
+
+Version 0.1
+
+2007-06-03  Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+	 * Initial version (0.1). For test only.
+
+	 * Show incoming messages and status messages in popup window
+
+


Property changes on: trunk/tkabber-plugins/floatinglog/ChangeLog
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/INSTALL
===================================================================
--- trunk/tkabber-plugins/floatinglog/INSTALL	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/INSTALL	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,9 @@
+Copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/floatinglog/
+  ~/.tkabber/plugins/floatinglog/floatinglog.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Set option Tkabber -> Plugins -> FloatingLog -> show_log to enable plugin.


Property changes on: trunk/tkabber-plugins/floatinglog/INSTALL
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/TODO
===================================================================
--- trunk/tkabber-plugins/floatinglog/TODO	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/TODO	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,6 @@
+Do not show messages from set_status hook but get all of them from other hooks
+Open chat window on left click on message
+Log grows up or down depends on position
+Allow to select colors for window in options
+Translation to other languages
+Do not show messages for selected groups in roster


Property changes on: trunk/tkabber-plugins/floatinglog/TODO
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/VERSION
===================================================================
--- trunk/tkabber-plugins/floatinglog/VERSION	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/VERSION	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,2 @@
+Version: 0.4
+Date: 2007-August-26


Property changes on: trunk/tkabber-plugins/floatinglog/VERSION
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/floatinglog.tcl
===================================================================
--- trunk/tkabber-plugins/floatinglog/floatinglog.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/floatinglog.tcl	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,387 @@
+# $Id$
+
+package require msgcat
+
+namespace eval floatinglog {
+
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    variable id 0
+    variable winname ".floatinglog"
+    variable idlestring [::msgcat::mc "Idle for %s"]
+    variable idlestring [string range $idlestring 0 [string length idlestring]]
+
+    #
+    # Options section
+    #
+    custom::defgroup Plugins [::msgcat::mc "Plugins options."] \
+	-group Tkabber
+    custom::defgroup {Floating Log} \
+	[::msgcat::mc "FloatingLog plugin options."] \
+	-group Plugins
+    custom::defgroup {Floating Log Window} \
+	[::msgcat::mc "FloatingLog window properties."] \
+	-group {Floating Log}
+    custom::defgroup {Floating Log Control} \
+	[::msgcat::mc "Message types to show."] \
+	-group {Floating Log}
+
+    custom::defvar options(show_log) 0 \
+	[::msgcat::mc "Show floating log"] \
+	-type boolean -group {Floating Log}
+
+    custom::defvar options(show_chat) 1 \
+	[::msgcat::mc "Show chat messages"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_groupchat) 1 \
+	[::msgcat::mc "Show groupchat messages"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_other_messages) 1 \
+	[::msgcat::mc "Show other messages"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_when_tkabber_is_active) 0 \
+	[::msgcat::mc "Show when Tkabber is active"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_on_away_status) 1 \
+	[::msgcat::mc "Show in \"Away\" status"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_on_xa_status) 1 \
+	[::msgcat::mc "Show in \"Extended away\" status"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_on_dnd_status) 0 \
+	[::msgcat::mc "Show in \"Do not disturb\" status"] \
+	-type boolean -group {Floating Log Control}
+
+    custom::defvar options(show_message_body) 1 \
+	[::msgcat::mc "Show incoming message body"] \
+	-type boolean -group {Floating Log Control}
+
+    
+    custom::defvar options(simple_show_scheme) 0 \
+	[::msgcat::mc "Use simple view scheme"] \
+	-type boolean -group {Floating Log Window}
+
+    custom::defvar options(alpha) 80 \
+	[::msgcat::mc "Window transparency percent"] \
+	-command [list [namespace current]::set_window] \
+	-type integer -group {Floating Log Window}
+
+    custom::defvar options(position) "-0-60" \
+	[::msgcat::mc "Window position"] \
+	-command [list [namespace current]::set_window] \
+	-type string -group {Floating Log Window}
+
+    custom::defvar options(width) 300 \
+	[::msgcat::mc "Window width"] \
+	-command [list [namespace current]::set_window] \
+	-type integer -group {Floating Log Window}
+
+    custom::defvar options(livetime) 5000 \
+	[::msgcat::mc "Delay before message hide (ms)"] \
+	-type integer -group {Floating Log}
+
+    #
+    # Color set
+    #
+    set message_foreground_color LightYellow
+    set message_background_color Black
+
+
+    set message_aspect 5000
+}
+
+#
+# Floating window initialization
+#
+proc floatinglog::window_initialization {} {
+    variable options
+    variable winname ".floatinglog"
+
+    toplevel $winname -relief flat -bd 1 -class Balloon
+    if {$::tcl_platform(platform) == "macintosh"} {
+	catch {unsupported1 style $winname floating sideTitlebar}
+    } elseif {$::aquaP} {
+	::tk::unsupported::MacWindowStyle style $winname help none    
+    } else {
+	wm transient $winname .
+	wm overrideredirect $winname 1
+    }
+
+    catch {
+	if {[lsearch -exact [wm attributes $winname] -topmost] >= 0} {
+	    wm attributes $winname -topmost 1
+	}
+    }
+
+    set_window
+    bind $winname <Button-3> [list wm withdraw $winname]
+    bind $winname <Double-ButtonPress-1> [namespace current]::left_double_click
+    hook::add set_status_hook [namespace current]::process_status
+    hook::add process_message_hook [namespace current]::process_message
+    wm withdraw $winname
+}
+ 
+proc floatinglog::left_double_click {} {
+    ::ifacetk::systray::restore
+    if {[focus] == ""} {
+	focus -force .
+    }
+}
+
+proc floatinglog::left_double_click_message {connid jid type} {
+    switch -- $type {
+	groupchat {
+	}
+	chat {
+	    chat::open_to_user $connid $jid
+	}
+	message {
+	    #message::send_dialog -to $jid
+	}
+    }
+}
+
+proc floatinglog::add_text {text {from ""} {connid ""} {type ""} \
+				 {is_subject ""} {subject ""}} {
+    variable options
+    variable id
+    variable winname
+    variable logfileId
+    variable message_background_color
+    variable message_foreground_color
+    variable message_aspect
+
+    if {!($options(show_log))} {return}
+
+    set active_window ""
+    set active_window [focus]
+    if {$active_window != "" && !$options(show_when_tkabber_is_active)} return
+
+    if {!$options(show_on_away_status) && $::curuserstatus == "away"} return
+
+    if {!$options(show_on_xa_status) && $::curuserstatus == "xa"} return
+
+    if {!$options(show_on_dnd_status) && $::curuserstatus == "dnd"} return
+
+    incr id
+    if {$options(simple_show_scheme)} {
+	add_text_scheme_simple $text $from $connid $type $is_subject $subject
+    } else {
+	add_text_scheme_01 $text $from $connid $type $is_subject $subject
+    }
+    
+    wm deiconify $winname
+}
+
+proc floatinglog::add_text_scheme_simple {body from connid type is_subject subject} {
+    variable options
+    variable id
+    variable winname
+    variable logfileId
+    variable message_background_color
+    variable message_foreground_color
+    variable message_aspect
+
+    if { $from != "" } {
+	if {[catch {::chat::get_nick $connid $from $type} nick]} {
+	    set nick [chat::get_nick $from $type]
+	}
+	if {!$options(show_message_body)} {
+	    set body [::msgcat::mc "Incoming message"]
+	}
+	set text [::msgcat::mc "FROM: "]
+	set formattext [append text  $nick " (" $from ")\n" "\n" $body]
+    } else {
+	set text $body
+    }
+
+    if {$text != ""} {
+	set message_name $winname.msg$id
+	message $message_name \
+		-text $text \
+		-width [expr $options(width) - 10] \
+		-justify left \
+		-aspect $message_aspect \
+		-bg [option get $winname background Balloon] \
+		-fg [option get $winname foreground Balloon] \
+		-relief solid -bd 1 -padx 3 -pady 3
+	set first_message [lindex [pack slaves $winname] 0]
+	if {$first_message == ""}  {
+	    pack $message_name -side bottom -fill x -padx 2 -pady 1
+	} else {
+	    pack $message_name -before $first_message \
+			       -side bottom -fill x -padx 2 -pady 1
+	}
+
+	if {($connid != "") && ($from != "") && ($type != "")} {
+	    bind $message_name <Double-ButtonPress-1> \
+		 +[list [namespace current]::left_double_click_message \
+			$connid $from $type]
+	}
+	after $options(livetime) [namespace current]::del_text "$message_name"
+    }
+} 
+
+proc floatinglog::add_text_scheme_01 {text from connid type is_subject subject} {
+    variable options
+    variable id
+    variable winname
+    variable logfileId
+    variable message_background_color
+    variable message_foreground_color
+    variable message_aspect
+
+
+    if {$text != ""} {
+	if { ! $options(show_message_body) && $from != "" } {
+	    set text [::msgcat::mc "Incoming message"]
+	}
+	set message_name $winname.msg$id
+	message $message_name \
+		-text $text \
+		-width [expr $options(width) - 10] \
+		-justify left \
+		-aspect $message_aspect \
+		-bg [option get $winname background Balloon] \
+		-fg [option get $winname foreground Balloon] \
+		-relief solid -bd 1 -padx 3 -pady 3
+    }
+    if {$from != ""} {
+	if {[catch {::chat::get_nick $connid $from $type} nick]} {
+	    set nick [chat::get_nick $from $type]
+	}
+	if {$nick != "" } {
+	    append nick " (" $from ")"
+	} else {
+	    set nick $from
+	}
+	set message_name_head $winname.msg${id}head
+	message $message_name_head \
+		-text $nick \
+		-width [expr $options(width) - 10] \
+		-justify left \
+		-aspect $message_aspect \
+		-bg [option get $winname background Balloon] \
+		-fg [option get $winname foreground Balloon] \
+		-relief flat -bd 1 -padx 0 -pady 0
+    }
+    set first_message [lindex [pack slaves $winname] 0]
+    if {$first_message == ""}  {
+	if {$text != ""} {
+	    pack $message_name -side bottom -fill x -padx 2 -pady 1
+	}
+	if {$from != ""} {
+	    pack $message_name_head -side bottom -fill x -padx 2 -pady 0
+	}
+    } else {
+	if {$text != ""} {
+	    pack $message_name -before $first_message \
+			       -side bottom -fill x -padx 2 -pady 1
+	}
+	if {$from != ""} {
+	    pack $message_name_head -before $first_message \
+				    -side bottom -fill x -padx 2 -pady 0
+	}
+    }
+
+    if {($connid != "") && ($from != "") && ($type != "")} {
+	if {$from != ""} { 
+	    bind $message_name_head <Double-ButtonPress-1> \
+		 +[list [namespace current]::left_double_click_message \
+			$connid $from $type]
+	}
+	if {$text != "" } { 
+	    bind $message_name <Double-ButtonPress-1> \
+		 +[list [namespace current]::left_double_click_message \
+			$connid $from $type]
+	}
+    }
+
+    after $options(livetime) [namespace current]::del_text "$message_name"
+}
+
+proc floatinglog::process_status {text} {
+    variable idlestring
+
+    if {[string first $idlestring $text] != -1} return
+    add_text $text
+}
+
+proc floatinglog::del_text {{msg ""}} {
+    variable winname
+
+    if {[winfo exists $msg]} {
+	pack forget $msg
+	destroy $msg
+    }
+    append msg head
+    if {[winfo exists $msg]} {
+	pack forget $msg
+	destroy $msg
+    }
+    if {[winfo children $winname] == ""} {
+	wm withdraw $winname
+    }
+}
+
+proc floatinglog::process_message {connid from id type is_subject \
+				   subject body err thread priority x} {
+    variable options
+
+    if {$body != ""} {
+	switch -exact $type {
+	    chat {
+		if {!$options(show_chat)} return
+	    }
+	    groupchat { 
+		if {!$options(show_groupchat)} return
+		if {[is_delayed $x]} return
+	    }
+	    default {
+		if {!$options(show_other_messages)} return
+	    }
+	}
+
+	catch {
+	    add_text $body $from $connid $type $is_subject $subject
+	}
+    }
+}
+
+
+proc floatinglog::is_delayed {xml} {
+    foreach xelem $xml {
+	::jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	switch -- [::jlib::wrapper:getattr $vars xmlns] {
+	    urn:xmpp:delay -
+	    jabber:x:delay {
+		return 1
+	    }
+	}
+    }
+    return 0
+}
+
+proc floatinglog::set_window {args} {
+    variable options
+    variable winname
+
+    catch {
+	if {[lsearch -exact [wm attributes $winname] -alpha] >= 0} {
+	    wm attributes $winname -alpha [expr $options(alpha) / 100.0]
+	}
+    }
+    wm minsize $winname $options(width) 10
+    wm maxsize $winname $options(width) 700
+    wm geometry $winname $options(position)
+} 
+
+hook::add finload_hook \
+	  [namespace current]::floatinglog::window_initialization 200
+


Property changes on: trunk/tkabber-plugins/floatinglog/floatinglog.tcl
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatinglog/license.terms
===================================================================
--- trunk/tkabber-plugins/floatinglog/license.terms	                        (rev 0)
+++ trunk/tkabber-plugins/floatinglog/license.terms	2007-10-06 11:36:57 UTC (rev 1245)
@@ -0,0 +1,19 @@
+Copyright (c) 2007 Rakhmanin Ruslan <rakhmaninr at mail.ru>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.


Property changes on: trunk/tkabber-plugins/floatinglog/license.terms
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native



More information about the Tkabber-dev mailing list