[Tkabber-dev] r1626 - in trunk/tkabber-plugins: . socials

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Jan 10 15:28:09 MSK 2009


Author: sergei
Date: 2009-01-10 15:28:09 +0300 (Sat, 10 Jan 2009)
New Revision: 1626

Added:
   trunk/tkabber-plugins/socials/preload.tcl
Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/socials/socials.tcl
Log:
	* socials/preload.tcl, socials/socials.tcl: Made socials plugin
	  unloadable without requiring Tkabber restart.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2009-01-10 12:26:35 UTC (rev 1625)
+++ trunk/tkabber-plugins/ChangeLog	2009-01-10 12:28:09 UTC (rev 1626)
@@ -1,3 +1,8 @@
+2009-01-10  Sergei Golovan <sgolovan at nes.ru>
+
+	* socials/preload.tcl, socials/socials.tcl: Made socials plugin
+	  unloadable without requiring Tkabber restart.
+
 2008-11-15  Sergei Golovan <sgolovan at nes.ru>
 
 	* whiteboard/svgrender.tcl, whiteboard/whiteboard.tcl: Added

Added: trunk/tkabber-plugins/socials/preload.tcl
===================================================================
--- trunk/tkabber-plugins/socials/preload.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/socials/preload.tcl	2009-01-10 12:28:09 UTC (rev 1626)
@@ -0,0 +1,13 @@
+# $Id$
+
+namespace eval socials {
+    set dir [file dirname [info script]]
+    ::plugins::register socials \
+			-namespace [namespace current] \
+			-source [file join $dir socials.tcl] \
+			-description [::msgcat::mc "Socials plugin is loaded."] \
+			-loadcommand [namespace code [list load [file join $dir socials.ru] koi8-r]] \
+			-unloadcommand [namespace code unload]
+    unset dir
+}
+


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

Modified: trunk/tkabber-plugins/socials/socials.tcl
===================================================================
--- trunk/tkabber-plugins/socials/socials.tcl	2009-01-10 12:26:35 UTC (rev 1625)
+++ trunk/tkabber-plugins/socials/socials.tcl	2009-01-10 12:28:09 UTC (rev 1626)
@@ -1,12 +1,47 @@
 # $Id$
 
-namespace eval socials {
-    set social_list {}
-}
+namespace eval socials {}
 
 proc socials::load {filename {enc utf-8}} {
+    variable social_list {}
     variable social
 
+    load_file $filename $enc
+    #puts [array get social]
+
+    #puts [socials::interp giggle asd ""]
+    #puts [socials::interp ÐÏÌÚÁÔØ asd qwe]
+
+    hook::add generate_completions_hook \
+	      [namespace current]::commands_comps 51
+
+    #puts [llength $social_list]
+
+    hook::add chat_send_message_hook \
+	      [namespace current]::handle_commands 50
+
+    return
+}
+
+proc socials::unload {} {
+    variable social_list
+    variable social
+
+    hook::remove chat_send_message_hook \
+		 [namespace current]::handle_commands 50
+
+    hook::remove generate_completions_hook \
+		 [namespace current]::commands_comps 51
+
+    catch {unset social_list}
+    catch {unset social}
+
+    return
+}
+
+proc socials::load_file {filename {enc utf-8}} {
+    variable social
+
     set f [file join [file dirname [info script]] $filename]
     set fd [open $f]
     fconfigure $fd -encoding $enc
@@ -38,7 +73,6 @@
     close $fd
 }
 
-
 proc socials::add {names} {
     variable social
     variable social_list
@@ -59,10 +93,6 @@
     }
 }
 
-
-socials::load socials.ru koi8-r
-#puts [array get socials::social]
-
 proc socials::substitute {s from to} {
     regsub -all {\$n\d?} $s /me s
     regsub -all {\$e\d?} $s /me s
@@ -82,9 +112,6 @@
     }
 }
 
-#puts [socials::interp giggle asd ""]
-#puts [socials::interp ÐÏÌÚÁÔØ asd qwe]
-
 proc socials::commands_comps {chatid compsvar wordstart line} {
     variable social_list
     upvar 0 $compsvar comps
@@ -97,11 +124,6 @@
     #debugmsg completion "SOC: $comps"
 }
 
-hook::add generate_completions_hook \
-    [namespace current]::socials::commands_comps 51
-
-#puts [llength $socials::social_list]
-
 proc socials::handle_commands {chatid user body type} {
     variable social_list
     variable social
@@ -140,5 +162,3 @@
     }
 }
 
-hook::add chat_send_message_hook \
-    [namespace current]::socials::handle_commands 50



More information about the Tkabber-dev mailing list