[Tkabber-dev] r1955 - in trunk/tkabber-plugins: . presencecmd presencecmd/msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Nov 12 03:45:04 MSK 2010


Author: kostix
Date: 2010-11-12 03:45:04 +0300 (Fri, 12 Nov 2010)
New Revision: 1955

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/presencecmd/msgs/ru.msg
   trunk/tkabber-plugins/presencecmd/presencecmd.tcl
Log:
Make presencecmd plugin dynamically loadable

Thanks to Serge Yudin.

Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2010-11-11 13:00:36 UTC (rev 1954)
+++ trunk/tkabber-plugins/ChangeLog	2010-11-12 00:45:04 UTC (rev 1955)
@@ -1,3 +1,8 @@
+2010-11-12  Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+	* presencecmd/presencecmd.tcl: Make presencecmd plugin dynamically
+	  loadable (thanks to Serge Yudin).
+
 2010-11-11  Sergei Golovan <sgolovan at nes.ru>
 
 	* openurl/openurl.tcl: Fixed typo and added Google Chrome browser.

Modified: trunk/tkabber-plugins/presencecmd/msgs/ru.msg
===================================================================
--- trunk/tkabber-plugins/presencecmd/msgs/ru.msg	2010-11-11 13:00:36 UTC (rev 1954)
+++ trunk/tkabber-plugins/presencecmd/msgs/ru.msg	2010-11-12 00:45:04 UTC (rev 1955)
@@ -18,4 +18,4 @@
 		    Где presence - одно из: avail\[able\], away, xa, dnd, chat.\n\
 		    Особое присутствие \"clear\[status\]\" очищает статусное сообщение.\n\
 		    /thispresence является синонимом /chatpresence"
-
+::msgcat::mcset ru "Whether the Presencecmd plugin is loaded." "Загружено ли расширение Presencecmd."

Modified: trunk/tkabber-plugins/presencecmd/presencecmd.tcl
===================================================================
--- trunk/tkabber-plugins/presencecmd/presencecmd.tcl	2010-11-11 13:00:36 UTC (rev 1954)
+++ trunk/tkabber-plugins/presencecmd/presencecmd.tcl	2010-11-12 00:45:04 UTC (rev 1955)
@@ -10,16 +10,31 @@
 package require msgcat
 
 namespace eval presencecmd {
-
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
+    if {![::plugins::is_registered presencecmd]} {
+        ::plugins::register presencecmd \
+            -namespace [namespace current] \
+            -source [info script] \
+            -description [::msgcat::mc "Whether the Presencecmd plugin is loaded."] \
+            -loadcommand [namespace code load] \
+            -unloadcommand [namespace code unload]
+        return
+    }
+}
 
+proc presencecmd::load {} {
     hook::add generate_completions_hook [namespace current]::command_comps
     hook::add chat_send_message_hook [namespace current]::handle_command 15
 }
 
+proc presencecmd::unload {} {
+    hook::remove generate_completions_hook [namespace current]::command_comps
+    hook::remove chat_send_message_hook [namespace current]::handle_command 15
+}
+
 proc presencecmd::command_comps {chatid compsvar wordstart line} {
     upvar 0 $compsvar comps
-    
+
     if {!$wordstart} {
 	lappend comps {/presence } {/chatpresence } {/thispresence }
     }



More information about the Tkabber-dev mailing list