[Tkabber-dev] r125 - trunk/plugins/openhistory

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Aug 19 19:56:01 MSD 2008


Author: asv
Date: 2008-08-19 19:56:00 +0400 (Tue, 19 Aug 2008)
New Revision: 125

Added:
   trunk/plugins/openhistory/license.terms
   trunk/plugins/openhistory/openhistory.tcl
Log:
added plugin files missed in previous commit


Added: trunk/plugins/openhistory/license.terms
===================================================================
--- trunk/plugins/openhistory/license.terms	                        (rev 0)
+++ trunk/plugins/openhistory/license.terms	2008-08-19 15:56:00 UTC (rev 125)
@@ -0,0 +1,19 @@
+Copyright (c) 2008 Alexey Smirnov <alexey.smirnov at gmx.com>
+
+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.

Added: trunk/plugins/openhistory/openhistory.tcl
===================================================================
--- trunk/plugins/openhistory/openhistory.tcl	                        (rev 0)
+++ trunk/plugins/openhistory/openhistory.tcl	2008-08-19 15:56:00 UTC (rev 125)
@@ -0,0 +1,60 @@
+# Allows to open history window without using mouse.
+# Usage: "/history jid"
+# Written by Alex Smirnov <sceptic13 at gmail.com>
+
+namespace eval openhistory {
+
+    hook::add generate_completions_hook [namespace current]::roster_compls
+    hook::add chat_send_message_hook [namespace current]::handle_command 15
+}
+
+proc openhistory::handle_command {chatid user body type} {
+    if {[string match {/history*} $body]} {
+        set cmd /history
+    } else return
+
+    set user [lindex [split $body] 1]
+    set connid [chat::get_connid $chatid]
+
+    if {![string length $user]} {
+        set jid [node_and_server_from_jid [chat::get_jid $chatid]]
+
+        ::logger::show_log $jid -connection $connid
+        return stop
+    }
+
+    if {[string first "@" $user] >= 0} {
+        ::logger::show_log $user -connection $connid
+    } else {
+        ::logger::show_log [chat::get_jid $chatid]/$user \
+            -connection $connid
+    }
+
+    return stop
+}
+
+proc openhistory::roster_compls {chatid compsvar wordstart line} {
+    upvar 0 $compsvar comps
+
+    if {!$wordstart} {
+        lappend comps {/history }
+    }
+
+    if {$wordstart && [string match {/history*} $line]} {
+        set prefix $plugins::completion::options(prefix)
+        set suffix $plugins::completion::options(suffix)
+
+        set jidcomps {}
+        set connid [chat::get_connid $chatid]
+
+        foreach jid [roster::get_jids $connid] {
+            if {[roster::itemconfig $connid $jid -isuser]} {
+                lappend jidcomps $prefix$jid$suffix
+            }
+        }
+
+        set jidcomps [lsort -dictionary -unique $jidcomps]
+        set comps [concat $comps $jidcomps]
+    }
+
+}



More information about the Tkabber-dev mailing list