[Tkabber-dev] r1722 - in trunk/tkabber-plugins: . custom-urls cyrillize ejabberd floatingcontact floatinglog georoster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Mar 13 20:03:35 MSK 2009


Author: sergei
Date: 2009-03-13 20:03:35 +0300 (Fri, 13 Mar 2009)
New Revision: 1722

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/custom-urls/custom-urls.tcl
   trunk/tkabber-plugins/cyrillize/cyrillize.tcl
   trunk/tkabber-plugins/ejabberd/ejabberd.tcl
   trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl
   trunk/tkabber-plugins/floatinglog/floatinglog.tcl
   trunk/tkabber-plugins/georoster/georoster.tcl
Log:
	* custom-urls/custom-urls.tcl, cyrillize/cyrillize.tcl,
	  ejabberd/ejabberd.tcl, floatingcontact/floatingcontact.tcl,
	  floatinglog/floatinglog.tcl, georoster/georoster.tcl: Made plugins
	  unloadable.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/ChangeLog	2009-03-13 17:03:35 UTC (rev 1722)
@@ -6,6 +6,11 @@
 	* openurl/openurl.tcl: Made plugin unloadable. Also, added a few
 	  browsers and a custom browser (thanks to Serge Yudin).
 
+	* custom-urls/custom-urls.tcl, cyrillize/cyrillize.tcl,
+	  ejabberd/ejabberd.tcl, floatingcontact/floatingcontact.tcl,
+	  floatinglog/floatinglog.tcl, georoster/georoster.tcl: Made plugins
+	  unloadable.
+
 2009-03-12  Sergei Golovan <sgolovan at nes.ru>
 
 	* whiteboard/svgrender.tcl, whiteboard/whiteboard.tcl: Switched to

Modified: trunk/tkabber-plugins/custom-urls/custom-urls.tcl
===================================================================
--- trunk/tkabber-plugins/custom-urls/custom-urls.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/custom-urls/custom-urls.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -6,7 +6,7 @@
 #    xep-0013 or jep-0013 or jep-13 or xep-13 or jep13 or xep13 ->
 #        http://www.xmpp.org/extensions/xep-0013.html
 # 2) RFC links:
-#    rfc-1111 -> http://rfc.net/rfc1111.html
+#    rfc-1111 -> http://tools.ietf.org/html/rfc1111
 # 3) Debian BTS links:
 #    bug-345678 or #345678 ->
 #        http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=345678
@@ -30,18 +30,53 @@
 #	[list [string map {bug tkbug} $re] \
 #	      "http://sourceforge.net/search/?type_of_search=artifact&group_id=12997&words=%d"]
 #}
-#
 
+package require msgcat
+
 namespace eval custom-urls {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered custom-urls]} {
+	::plugins::register custom-urls \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Custom URLs plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
     variable url
+    array set url {}
+}
+
+###############################################################################
+
+proc custom-urls::load {} {
+    variable url
+
     set url(xep)    [list {\y((?:jep|xep)(?:-|\s+)?(\d+))\y} \
 			  "http://www.xmpp.org/extensions/xep-%04d.html"]
     set url(rfc)    [list {\y(rfc(?:-|\s+)?(\d+))\y} \
-			  "http://rfc.net/rfc%04d.html"]
+			  "http://tools.ietf.org/html/rfc%d"]
     set url(debbug) [list {(?:^|\s)((?:(?:bug(?:-|\s+)?\#?)|\#)(\d+))\y} \
 			  "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%d"]
+
+    ::richtext::register_entity custom-url \
+	    -parser [namespace current]::process_urls \
+	    -parser-priority 55
+
+    ::richtext::entity_state custom-url 1
 }
 
+proc custom-urls::unload {} {
+    variable url
+
+    ::richtext::unregister_entity custom-url
+
+    array unset url
+}
+
 ###############################################################################
 
 # This proc actually uses "url" rich text entity and relies on its
@@ -126,14 +161,4 @@
 
 ###############################################################################
 
-namespace eval custom-urls {
-    ::richtext::register_entity custom-url \
-	-parser [namespace current]::process_urls \
-	-parser-priority 55
-
-    ::richtext::entity_state custom-url 1
-}
-
-###############################################################################
-
 # vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber-plugins/cyrillize/cyrillize.tcl
===================================================================
--- trunk/tkabber-plugins/cyrillize/cyrillize.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/cyrillize/cyrillize.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -1,13 +1,73 @@
 # $Id$
 
+package require msgcat
+
 namespace eval cyrillize {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered cyrillize]} {
+	::plugins::register cyrillize \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Cyrillize plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
 }
 
-proc cyrillize::load_table {} {
+proc cyrillize::load {} {
+    load_table [file join [file dirname [info script]] engrus.tbl]
+
+    event add <<Cyrillize-Eng-Rus>> <Control-quoteright>
+    event add <<Cyrillize-Eng-Rus>> <Control-yacute>
+    event add <<Cyrillize-Rus-Eng>> <Control-quotedbl>
+    event add <<Cyrillize-Rus-Eng>> <Control-Yacute>
+
+    bind Text <<Cyrillize-Eng-Rus>> \
+	 [list [namespace current]::wordInText %W eng rus]
+    bind Text <<Cyrillize-Eng-Rus>> +break
+    bind Text <<Cyrillize-Rus-Eng>> \
+	 [list [namespace current]::wordInText %W rus eng]
+    bind Text <<Cyrillize-Rus-Eng>> +break
+
+    bind Entry <<Cyrillize-Eng-Rus>> \
+	 [list [namespace current]::wordInEntry %W eng rus]
+    bind Entry <<Cyrillize-Eng-Rus>> +break
+    bind Entry <<Cyrillize-Rus-Eng>> \
+	 [list [namespace current]::wordInEntry %W rus eng]
+    bind Entry <<Cyrillize-Rus-Eng>> +break
+
+    bind BwEntry <<Cyrillize-Eng-Rus>> \
+	 [list [namespace current]::wordInEntry %W eng rus]
+    bind BwEntry <<Cyrillize-Eng-Rus>> +break
+    bind BwEntry <<Cyrillize-Rus-Eng>> \
+	 [list [namespace current]::wordInEntry %W rus eng]
+    bind BwEntry <<Cyrillize-Rus-Eng>> +break
+}
+
+proc cyrillize::unload {} {
     variable convert
 
-    set f [file join [file dirname [info script]] engrus.tbl]
-    set fd [open $f]
+    bind Text <<Cyrillize-Eng-Rus>> {}
+    bind Text <<Cyrillize-Rus-Eng>> {}
+    bind Entry <<Cyrillize-Eng-Rus>> {}
+    bind Entry <<Cyrillize-Rus-Eng>> {}
+    bind BwEntry <<Cyrillize-Eng-Rus>> {}
+    bind BwEntry <<Cyrillize-Rus-Eng>> {}
+
+    event delete <<Cyrillize-Eng-Rus>> <Control-quoteright>
+    event delete <<Cyrillize-Eng-Rus>> <Control-yacute>
+    event delete <<Cyrillize-Rus-Eng>> <Control-quotedbl>
+    event delete <<Cyrillize-Rus-Eng>> <Control-Yacute>
+
+    catch {unset convert}
+}
+
+proc cyrillize::load_table {filename} {
+    variable convert
+
+    set fd [open $filename]
     fconfigure $fd -encoding koi8-r
     set convert_table [read $fd]
     close $fd
@@ -18,10 +78,6 @@
     }
 }
 
-cyrillize::load_table
-
-#puts [array get cyrillize::engrus]
-
 proc cyrillize::do {s from to} {
     variable convert
 
@@ -38,8 +94,6 @@
     return $res
 }
 
-#puts [cyrillize::do Ghbdtn]
-
 proc cyrillize::wordInText {w from to} {
     if {[$w cget -state] != "normal"} return
 
@@ -76,29 +130,3 @@
     $w icursor $wordend
 }
 
-event add <<Cyrillize-Eng-Rus>> <Control-quoteright>
-event add <<Cyrillize-Eng-Rus>> <Control-yacute>
-event add <<Cyrillize-Rus-Eng>> <Control-quotedbl>
-event add <<Cyrillize-Rus-Eng>> <Control-Yacute>
-
-bind Text <<Cyrillize-Eng-Rus>> \
-     [list [namespace current]::cyrillize::wordInText %W eng rus]
-bind Text <<Cyrillize-Eng-Rus>> +break
-bind Text <<Cyrillize-Rus-Eng>> \
-     [list [namespace current]::cyrillize::wordInText %W rus eng]
-bind Text <<Cyrillize-Rus-Eng>> +break
-
-bind Entry <<Cyrillize-Eng-Rus>> \
-     [list [namespace current]::cyrillize::wordInEntry %W eng rus]
-bind Entry <<Cyrillize-Eng-Rus>> +break
-bind Entry <<Cyrillize-Rus-Eng>> \
-     [list [namespace current]::cyrillize::wordInEntry %W rus eng]
-bind Entry <<Cyrillize-Rus-Eng>> +break
-
-bind BwEntry <<Cyrillize-Eng-Rus>> \
-     [list [namespace current]::cyrillize::wordInEntry %W eng rus]
-bind BwEntry <<Cyrillize-Eng-Rus>> +break
-bind BwEntry <<Cyrillize-Rus-Eng>> \
-     [list [namespace current]::cyrillize::wordInEntry %W rus eng]
-bind BwEntry <<Cyrillize-Rus-Eng>> +break
-

Modified: trunk/tkabber-plugins/ejabberd/ejabberd.tcl
===================================================================
--- trunk/tkabber-plugins/ejabberd/ejabberd.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/ejabberd/ejabberd.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -2,16 +2,65 @@
 
 package require msgcat
 
-::msgcat::mcload [file join [file dirname [info script]] msgs]
+namespace eval ejabberd {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
-namespace eval ejabberd {
+    if {![::plugins::is_registered ejabberd]} {
+	::plugins::register ejabberd \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Ejabberd plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
     custom::defvar ejabberd_server_list {} \
 	[::msgcat::mc "List of ejabberd servers."] \
 	-group Hidden
 }
 
-set ::NS_ECONFIGURE "http://ejabberd.jabberstudio.org/protocol/configure"
+proc ejabberd::load {} {
+    variable NS_ECONFIGURE
+    variable data
 
+    set data(windows) {}
+
+    set NS_ECONFIGURE "http://ejabberd.jabberstudio.org/protocol/configure"
+
+    hook::add finload_hook [namespace current]::setup_menu
+
+    disco::browser::register_feature_handler $NS_ECONFIGURE \
+		[namespace current]::open_win \
+		-desc [list * [::msgcat::mc "Administrate ejabberd"]]
+
+    setup_menu
+}
+
+proc ejabberd::unload {} {
+    variable NS_ECONFIGURE
+    variable data
+
+    disco::browser::unregister_feature_handler $NS_ECONFIGURE
+
+    catch {
+        set m [.mainframe getmenu admin]
+	set idx [$m index [::msgcat::mc "Administrate ejabberd..."]]
+        $m delete $idx
+    }
+
+    catch { destroy .ejabberdserver }
+
+    foreach w $data(windows) {
+	destroy_win $w
+    }
+
+    hook::remove finload_hook [namespace current]::setup_menu
+
+    catch {unset data}
+    catch {unset NS_ECONFIGURE}
+}
+
 proc ejabberd::setup_menu {} {
     catch {
         set m [.mainframe getmenu admin]
@@ -21,12 +70,6 @@
     }
 }
 
-hook::add finload_hook [namespace current]::ejabberd::setup_menu
-
-disco::browser::register_feature_handler $::NS_ECONFIGURE \
-    [namespace current]::ejabberd::open_win \
-    -desc [list * [::msgcat::mc "Administrate ejabberd"]]
-
 proc ejabberd::ask_server_dialog {} {
     global ejabberd_server
     global ejabberd_xlib
@@ -101,14 +144,17 @@
     open_win $xlib $ejabberd_server
 }
 
+proc ejabberd::open_win {xlib jid args} {
+    variable data
 
-proc ejabberd::open_win {xlib jid args} {
     set w [win_id ejabberd $xlib:$jid]
     if {[winfo exists $w]} {
 	raise_win $w
 	return
     }
 
+    lappend data(windows) $w
+
     set title [::msgcat::mc "%s administration" $jid]
     add_win $w -title $title \
 	       -tabtitle $jid \
@@ -119,7 +165,7 @@
     pack $nb -fill both -expand yes
 
     # Binding $nb, not $w to avoid multiple calls if $w is a toplevel
-    bind $nb <Destroy> [list [namespace current]::cleanup $xlib $jid]
+    bind $nb <Destroy> [list [namespace current]::cleanup $xlib $jid $w]
 
     foreach {page title} \
 	[list main   [::msgcat::mc "Main"] \
@@ -134,7 +180,7 @@
     $nb raise main
 }
 
-proc ejabberd::cleanup {xlib jid} {
+proc ejabberd::cleanup {xlib jid w} {
     variable data
 
     catch {unset data($xlib,$jid,total_users)}
@@ -149,6 +195,11 @@
     catch {unset data($xlib,$jid,access_rules)}
     catch {unset data($xlib,$jid,last)}
     catch {unset data($xlib,$jid,last_int)}
+
+    set idx [lsearch -exact $data(windows) $w]
+    if {$idx >= 0} {
+	set data(windows) [lreplace $data(windows) $idx $idx]
+    }
 }
 
 proc ejabberd::add_grid_record {xlib jid info name desc row} {
@@ -196,9 +247,11 @@
 }
 
 proc ejabberd::reload_page_main {f xlib jid} {
+    variable NS_ECONFIGURE
+
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create info \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_main_info $f $xlib $jid]
 }
@@ -246,15 +299,17 @@
 }
 
 proc ejabberd::reload_page_reg {f xlib jid} {
+    variable NS_ECONFIGURE
+
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create welcome-message \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_welcome_message $f $xlib $jid]
 
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create registration-watchers \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_registration_watchers $f $xlib $jid]
 }
@@ -293,7 +348,6 @@
     $wbody insert 0.0 $body
 }
 
-
 proc ejabberd::parse_registration_watchers {f xlib jid status xml} {
     variable data
 
@@ -324,8 +378,6 @@
     $wwatchers insert 0.0 [join $jids \n]
 }
 
-
-
 proc ejabberd::fill_page_access {f xlib jid} {
     variable data
 
@@ -349,15 +401,17 @@
 }
 
 proc ejabberd::reload_page_access {f xlib jid} {
+    variable NS_ECONFIGURE
+
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create acls \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_access acls $f $xlib $jid]
 
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create access \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_access access_rules $f $xlib $jid]
 }
@@ -382,7 +436,6 @@
     $w insert 0.0 $cdata
 }
 
-
 proc ejabberd::fill_page_last {f xlib jid} {
     variable data
 
@@ -420,9 +473,11 @@
 }
 
 proc ejabberd::reload_page_last {f xlib jid} {
+    variable NS_ECONFIGURE
+
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create last \
-			-xmlns $::NS_ECONFIGURE] \
+			-xmlns $NS_ECONFIGURE] \
 	-to $jid \
 	-command [list [namespace current]::parse_last $f $xlib $jid]
 }
@@ -504,3 +559,4 @@
     $plot scale all 0 0 1 [expr {0.9 * $height / (0.0 + $y2 - $y1)}]
     $plot configure -scrollregion [$plot bbox all]
 }
+

Modified: trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl
===================================================================
--- trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -5,9 +5,67 @@
 
 package require msgcat
 
-namespace eval ::ifacetk::roster {
+namespace eval floatingcontact {
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
+    if {![::plugins::is_registered floatingcontact]} {
+	::plugins::register floatingcontact \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Floating Contact plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+}
+
+proc floatingcontact::load {} {
+    hook::add connected_hook ::ifacetk::roster::load_float_list
+    hook::add disconnected_hook ::ifacetk::roster::save_float_list
+    hook::add client_presence_hook ::ifacetk::roster::float_on_change_jid_presence 100
+    hook::add roster_service_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+    hook::add roster_jid_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+
+    foreach xlib [connections] {
+	::ifacetk::roster::load_float_list $xlib
+    }
+}
+
+proc floatingcontact::unload {} {
+    foreach xlib [connections] {
+	::ifacetk::roster::save_float_list $xlib
+    }
+
+    hook::remove connected_hook ::ifacetk::roster::load_float_list
+    hook::remove disconnected_hook ::ifacetk::roster::save_float_list
+    hook::remove client_presence_hook ::ifacetk::roster::float_on_change_jid_presence 100
+    hook::remove roster_service_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+    hook::remove roster_jid_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+
+    foreach proc {load_float_list
+		  save_float_list
+		  float_toggle
+		  float_redraw
+		  float_on_change_jid_presence
+		  float_start_drag
+		  float_motion_drag
+		  float_stop_drag
+		  float_create_menu} {
+	rename ::ifacetk::roster::$proc ""
+    }
+
+    foreach var {float_winid
+		 float_savex
+		 float_savey
+		 float_x
+		 float_y
+		 float_is_float
+		 float_floats} {
+	catch {unset ::ifacetk::roster::$var}
+    }
+}
+
+namespace eval ::ifacetk::roster {
     variable float_winid 0
 
 #   {jid1 {rjid1 1 x y rjid2 0 x y} jid2 {rjid3 0 x y rjid4 0 x y}}
@@ -36,8 +94,6 @@
     }
 }
 
-hook::add connected_hook ::ifacetk::roster::load_float_list
-
 proc ::ifacetk::roster::save_float_list {xlib} {
     variable floating_jids_list
     variable float_is_float
@@ -76,11 +132,6 @@
     set floating_jids_list [array get fl]
 }
 
-hook::add disconnected_hook ::ifacetk::roster::save_float_list
-
-
-###############################################################################
-
 proc ::ifacetk::roster::float_toggle {xlib jid} {
     variable float_is_float
     variable float_x
@@ -145,8 +196,6 @@
     }
 }
 
-###############################################################################
-
 proc ::ifacetk::roster::float_redraw {xlib} {
     variable float_floats
     variable config
@@ -184,15 +233,10 @@
     }
 }
 
-###############################################################################
-
 proc ::ifacetk::roster::float_on_change_jid_presence {xlib jid type x args} {
     after idle [list [namespace current]::float_redraw $xlib]
 }
 
-hook::add client_presence_hook ::ifacetk::roster::float_on_change_jid_presence 100
-
-###############################################################################
 proc ::ifacetk::roster::float_start_drag {x y} {
     variable float_savex $x
     variable float_savey $y
@@ -215,8 +259,6 @@
     catch {unset float_savey}
 }
 
-###############################################################################
-
 proc ::ifacetk::roster::float_create_menu {m xlib jid} {
     set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
@@ -228,8 +270,3 @@
 	   -command [list [namespace current]::float_toggle $xlib $rjid]
 }
 
-hook::add roster_service_popup_menu_hook ::ifacetk::roster::float_create_menu 80
-hook::add roster_jid_popup_menu_hook ::ifacetk::roster::float_create_menu 80
-
-###############################################################################
-

Modified: trunk/tkabber-plugins/floatinglog/floatinglog.tcl
===================================================================
--- trunk/tkabber-plugins/floatinglog/floatinglog.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/floatinglog/floatinglog.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -3,12 +3,21 @@
 package require msgcat
 
 namespace eval floatinglog {
-
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
+    if {![::plugins::is_registered floatinglog]} {
+	::plugins::register floatinglog \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Floating Log plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
     variable id 0
     variable winname .floatinglog
-    variable ignore_message_list ""
+    variable ignore_message_list {}
     lappend ignore_message_list [string map {%s *} [::msgcat::mc "Idle for %s"]]
     set request_from [string map {%s *} [::msgcat::mc "%s request from %s"]]
     lappend ignore_message_list [string replace $request_from \
@@ -19,6 +28,7 @@
 			[string first * $request_from] ibb]
     lappend ignore_message_list [string map {%s *} \
 			[::msgcat::mc "Login retry for %s in %s"]]
+    unset request_from
 
     #
     # Options section
@@ -110,6 +120,30 @@
 	-type integer -group {Floating Log}
 }
 
+proc floatinglog::load {} {
+    hook::add finload_hook [namespace current]::window_initialization 200
+
+    window_initialization
+
+    hook::add set_status_hook [namespace current]::process_status
+    hook::add process_message_hook [namespace current]::process_message
+}
+
+proc floatinglog::unload {} {
+    variable id
+    variable winname
+    variable ignore_message_list
+
+    hook::remove set_status_hook [namespace current]::process_status
+    hook::remove process_message_hook [namespace current]::process_message
+    hook::remove finload_hook [namespace current]::window_initialization 200
+
+    catch {destroy $winname}
+    catch {unset id}
+    catch {unset winname}
+    catch {unset ignore_message_list}
+}
+
 #
 # Floating window initialization
 #
@@ -117,6 +151,10 @@
     variable options
     variable winname
 
+    if {[winfo exists $winname]} {
+	destroy $winname
+    }
+
     toplevel $winname -bd 0 -class Balloon
     if {$::tcl_platform(platform) == "macintosh"} {
 	catch {unsupported1 style $winname floating sideTitlebar}
@@ -136,8 +174,6 @@
     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
 }
  
@@ -385,7 +421,4 @@
     wm geometry $winname $options(position)
 } 
 
-hook::add finload_hook \
-	  [namespace current]::floatinglog::window_initialization 200
-
 # vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber-plugins/georoster/georoster.tcl
===================================================================
--- trunk/tkabber-plugins/georoster/georoster.tcl	2009-03-13 16:09:43 UTC (rev 1721)
+++ trunk/tkabber-plugins/georoster/georoster.tcl	2009-03-13 17:03:35 UTC (rev 1722)
@@ -3,8 +3,6 @@
 ###############################################################################
 
 package require msgcat
-package require http 2
-package require xmpp::private
 
 ###############################################################################
 
@@ -13,11 +11,21 @@
 ###############################################################################
 
 namespace eval georoster {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered georoster]} {
+	::plugins::register georoster \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Georoster plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
     variable georoster
     variable options
 
-    ::msgcat::mcload [file join [file dirname [info script]] msgs]
-
     if {![info exists options(citiesfile)]} {
 	set options(citiesfile) [file join [file dirname [info script]] earth]
 	foreach pr [::msgcat::mcpreferences] {
@@ -95,9 +103,59 @@
 
     variable showcities $opt2label($options(showcities))
     trace variable [namespace current]::showcities w \
-	[namespace current]::set_option_showcities
+		   [namespace current]::set_option_showcities
 }
 
+package require http 2
+package require xmpp::private
+
+proc georoster::load {} {
+    hook::add finload_hook [namespace current]::setup
+    hook::add client_presence_hook [namespace current]::presence_change
+    hook::add connected_hook [namespace current]::init 1
+    hook::add connected_hook [namespace current]::retrieve
+    hook::add save_session_hook [namespace current]::save_session
+
+    setup
+
+    foreach xlib [connections] {
+	init $xlib
+	retrieve $xlib
+    }
+}
+
+proc georoster::unload {} {
+    hook::remove finload_hook [namespace current]::setup
+    hook::remove client_presence_hook [namespace current]::presence_change
+    hook::remove connected_hook [namespace current]::init 1
+    hook::remove connected_hook [namespace current]::retrieve
+    hook::remove save_session_hook [namespace current]::save_session
+
+    catch {
+	set m [.mainframe getmenu roster]
+	set idx [$m index [::msgcat::mc "Georoster"]]
+	$m delete $idx
+    }
+
+    destroy_win .georoster
+
+    variable mapimage
+    variable georoster
+    variable status
+    variable geo3166
+    variable move
+    variable cities
+
+    image delete $mapimage
+
+    catch {unset mapimage}
+    catch {unset georoster}
+    catch {unset status}
+    catch {unset geo3166}
+    catch {unset move}
+    catch {unset cities}
+}
+
 ###############################################################################
 
 proc georoster::set_showcities {args} {
@@ -136,8 +194,6 @@
 	-command [list [namespace current]::open_georoster -raise 1]
 }
 
-hook::add finload_hook [namespace current]::georoster::setup
-
 ###############################################################################
 
 proc georoster::open_georoster {args} {
@@ -446,8 +502,6 @@
     redraw .georoster.c
 }
 
-hook::add client_presence_hook [namespace current]::georoster::presence_change
-
 ###############################################################################
 
 proc georoster::parse_vcard {w xlib jid status xml} {
@@ -831,8 +885,6 @@
     }
 }
 
-hook::add connected_hook [namespace current]::georoster::init 1
-
 ###############################################################################
 
 proc georoster::retrieve {xlib} {
@@ -841,8 +893,6 @@
 	    -command [list [namespace current]::recv $xlib]
 }
 
-hook::add connected_hook [namespace current]::georoster::retrieve
-
 ###############################################################################
 
 proc georoster::recv {xlib status xmllist} {
@@ -915,8 +965,6 @@
 	[lsort -command [namespace current]::compare_lo $cities(list)]
 }
 
-#georoster::load_cities
-
 ###############################################################################
 
 proc georoster::redraw_cities {c} {
@@ -978,8 +1026,6 @@
     $c lower text oval
 }
 
-#georoster::redraw_cities .georoster.c
-
 ###############################################################################
 
 proc georoster::load_3166 {} {
@@ -1047,8 +1093,6 @@
     }
 }
 
-hook::add save_session_hook [namespace current]::georoster::save_session
-
 ###############################################################################
 
 # vim:ts=8:sw=4:sts=4:noet



More information about the Tkabber-dev mailing list