[Tkabber-dev] r1744 - in trunk/tkabber-plugins: . checkers chess gmail iconsets mute poker renju reversi

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Mar 25 22:39:09 MSK 2009


Author: sergei
Date: 2009-03-25 22:39:09 +0300 (Wed, 25 Mar 2009)
New Revision: 1744

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/checkers/checkers.tcl
   trunk/tkabber-plugins/chess/chess.tcl
   trunk/tkabber-plugins/gmail/gmail.tcl
   trunk/tkabber-plugins/iconsets/iconsets.tcl
   trunk/tkabber-plugins/mute/mute.tcl
   trunk/tkabber-plugins/poker/poker.tcl
   trunk/tkabber-plugins/renju/renju.tcl
   trunk/tkabber-plugins/reversi/reversi.tcl
Log:
	* gmail/gmail.tcl, iconsets/iconsets.tcl, mute/mute.tcl: Made Gmail,
	  iconsets and MUTE plugins unloadable.

	* checkers/checkers.tcl, chess/chess.tcl, poker/poker.tcl,
	  renju/renju.tcl, reversi/reversi.tcl: Removed useless procedures from
	  postload and finload hooks.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/ChangeLog	2009-03-25 19:39:09 UTC (rev 1744)
@@ -1,3 +1,12 @@
+2009-03-25  Sergei Golovan <sgolovan at nes.ru>
+
+	* gmail/gmail.tcl, iconsets/iconsets.tcl, mute/mute.tcl: Made Gmail,
+	  iconsets and MUTE plugins unloadable.
+
+	* checkers/checkers.tcl, chess/chess.tcl, poker/poker.tcl,
+	  renju/renju.tcl, reversi/reversi.tcl: Removed useless procedures from
+	  postload and finload hooks.
+
 2009-03-22  Sergei Golovan <sgolovan at nes.ru>
 
 	* aniemoticons/msgs/de.msg, floatingcontact/msgs/de.msg,

Modified: trunk/tkabber-plugins/checkers/checkers.tcl
===================================================================
--- trunk/tkabber-plugins/checkers/checkers.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/checkers/checkers.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -81,10 +81,6 @@
 }
 
 proc checkers::load {} {
-    hook::add postload_hook [namespace current]::load_stored_theme 70
-
-    hook::add finload_hook [namespace current]::calc_moves 100
-
     hook::add roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.1
     hook::add chat_create_user_menu_hook \
@@ -105,10 +101,6 @@
 }
 
 proc checkers::unload {} {
-    hook::remove postload_hook [namespace current]::load_stored_theme 70
-
-    hook::remove finload_hook [namespace current]::calc_moves 100
-
     hook::remove roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.1
     hook::remove chat_create_user_menu_hook \

Modified: trunk/tkabber-plugins/chess/chess.tcl
===================================================================
--- trunk/tkabber-plugins/chess/chess.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/chess/chess.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -80,10 +80,6 @@
 }
 
 proc chess::load {} {
-    hook::add postload_hook [namespace current]::load_stored_theme 70
-
-    hook::add finload_hook [namespace current]::calc_moves 100
-
     hook::add roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48
     hook::add chat_create_user_menu_hook \
@@ -104,10 +100,6 @@
 }
 
 proc chess::unload {} {
-    hook::remove postload_hook [namespace current]::load_stored_theme 70
-
-    hook::remove finload_hook [namespace current]::calc_moves 100
-
     hook::remove roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48
     hook::remove chat_create_user_menu_hook \

Modified: trunk/tkabber-plugins/gmail/gmail.tcl
===================================================================
--- trunk/tkabber-plugins/gmail/gmail.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/gmail/gmail.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -3,9 +3,18 @@
 package require msgcat
 
 namespace eval gmail {
-
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
 
+    if {![::plugins::is_registered gmail]} {
+	::plugins::register gmail \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Gmail plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
     set ::NS(gnotify) "google:mail:notify"
 
     custom::defgroup Plugins \
@@ -36,11 +45,42 @@
 	-type string -group Hidden
 }
 
+package require md5
+
+proc gmail::load {} {
+    hook::add connected_hook [namespace current]::request_notifications
+    hook::add finload_hook [namespace current]::create_menu
+    hook::add save_session_hook [namespace current]::save_session
+
+    create_menu
+    request_all_notifications
+}
+
+proc gmail::unload {} {
+    hook::remove connected_hook [namespace current]::request_notifications
+    hook::remove finload_hook [namespace current]::create_menu
+    hook::remove save_session_hook [namespace current]::save_session
+
+    catch {
+	set menu [.mainframe getmenu plugins]
+	set idx [$menu index [::msgcat::mc "Open Gmail notifications"]]
+	$menu delete $idx
+    }
+
+    destroy_win .gmail_messages
+
+    unset $::NS(gnotify)
+}
+
 ############################################################################
 
 proc gmail::request_all_notifications {args} {
-    foreach xlib [connections] {
-	request_notifications $xlib
+    variable options
+
+    if {$options(gmail_notifications)} {
+	foreach xlib [connections] {
+	    request_notifications $xlib
+	}
     }
 }
 
@@ -68,8 +108,6 @@
     }
 }
 
-hook::add connected_hook [namespace current]::gmail::request_notifications
-
 ############################################################################
 
 proc gmail::receive_notifications {jid status xml} {
@@ -93,14 +131,14 @@
 #############################################################################
 
 proc gmail::create_menu {} {
-    set menu [.mainframe getmenu plugins]
-    $menu add command \
-	  -label [::msgcat::mc "Open Gmail notifications"] \
-	  -command [list [namespace current]::open_window -raise 1]
+    catch {
+	set menu [.mainframe getmenu plugins]
+	$menu add command \
+	      -label [::msgcat::mc "Open Gmail notifications"] \
+	      -command [list [namespace current]::open_window -raise 1]
+    }
 }
 
-hook::add finload_hook [namespace current]::gmail::create_menu
-
 #############################################################################
 
 proc gmail::open_window {args} {
@@ -186,8 +224,6 @@
     }
 }
 
-package require md5
-
 proc gmail::add_thread {jid tid messages date url xmlList unseen} {
     variable options
 
@@ -599,7 +635,5 @@
     }
 }
 
-hook::add save_session_hook [namespace current]::gmail::save_session
-
 #############################################################################
 

Modified: trunk/tkabber-plugins/iconsets/iconsets.tcl
===================================================================
--- trunk/tkabber-plugins/iconsets/iconsets.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/iconsets/iconsets.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -1,9 +1,39 @@
 # $Id$
 # Several iconsets, borrowed from other Jabber clients.
 
+package require msgcat
+
 namespace eval iconsets {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered iconsets]} {
+	::plugins::register iconsets \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Iconsets plugin is loaded."] \
+			    -loadcommand [namespace code [list load [file dirname [info script]]]] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+}
+
+proc iconsets::load {dirname} {
     set ::pixmaps::theme_dirs \
 	[concat $::pixmaps::theme_dirs \
-		[glob -nocomplain -directory [file dirname [info script]] *]]
+		[glob -nocomplain -directory $dirname *]]
+
+    ::pixmaps::load_themes
+    ::pixmaps::init_custom
+    ::pixmaps::load_stored_theme
 }
 
+proc iconsets::unload {} {
+    set ::pixmaps::theme_dirs \
+	[concat [glob -nocomplain -directory [file join $::configdir pixmaps] *] \
+		[glob -nocomplain -directory [fullpath pixmaps] *]]
+
+    ::pixmaps::load_themes
+    ::pixmaps::init_custom
+    ::pixmaps::load_stored_theme
+}
+

Modified: trunk/tkabber-plugins/mute/mute.tcl
===================================================================
--- trunk/tkabber-plugins/mute/mute.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/mute/mute.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -1,15 +1,62 @@
 # $Id$
 
-set ::NS(mute_ancestor) "http://jabber.org/protocol/mute#ancestor"
-set ::NS(mute_editor) "http://jabber.org/protocol/mute#editor"
-
 package require msgcat
 
-namespace eval mute {}
-namespace eval mute::editor {
+namespace eval mute {
     ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered mute]} {
+	::plugins::register mute \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Whether the Multi-User Text Editor plugin is loaded."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+
 }
 
+proc mute::load {} {
+    set ::NS(mute_ancestor) "http://jabber.org/protocol/mute#ancestor"
+    set ::NS(mute_editor) "http://jabber.org/protocol/mute#editor"
+
+    hook::add roster_create_groupchat_user_menu_hook \
+	      [namespace current]::editor::add_user_menu_item 49
+    hook::add chat_create_user_menu_hook \
+	      [namespace current]::editor::add_user_menu_item 49
+    hook::add roster_jid_popup_menu_hook \
+	      [namespace current]::editor::add_user_menu_item 49
+
+    ::xmpp::iq::register set * $::NS(mute_editor) \
+			 [namespace current]::editor::recv_set_iq
+    ::xmpp::iq::register get * $::NS(mute_ancestor) \
+			 [namespace current]::ancestor::recv_get_iq
+    ::xmpp::iq::register set * $::NS(mute_ancestor) \
+			 [namespace current]::ancestor::recv_set_iq
+}
+
+proc mute::unload {} {
+    hook::remove roster_create_groupchat_user_menu_hook \
+		 [namespace current]::editor::add_user_menu_item 49
+    hook::remove chat_create_user_menu_hook \
+		 [namespace current]::editor::add_user_menu_item 49
+    hook::remove roster_jid_popup_menu_hook \
+		 [namespace current]::editor::add_user_menu_item 49
+
+    ::xmpp::iq::unregister set * $::NS(mute_editor)
+    ::xmpp::iq::unregister get * $::NS(mute_ancestor)
+    ::xmpp::iq::unregister set * $::NS(mute_ancestor)
+
+    catch {unset ::NS(mute_ancestor)}
+    catch {unset ::NS(mute_editor)}
+
+    namespace delete [namespace current]::editor
+    namespace delete [namespace current]::ancestor
+}
+
+namespace eval mute::editor {}
+
 proc mute::editor::get_winid {xlib jid id} {
     return [win_id mute [list $xlib $jid]//@mute@//$id]
 }
@@ -20,14 +67,6 @@
 	-command [list [namespace current]::list_request $xlib $jid]
 }
 
-hook::add roster_create_groupchat_user_menu_hook \
-    [namespace current]::mute::editor::add_user_menu_item 49
-hook::add chat_create_user_menu_hook \
-    [namespace current]::mute::editor::add_user_menu_item 49
-hook::add roster_jid_popup_menu_hook \
-    [namespace current]::mute::editor::add_user_menu_item 49
-
-
 proc mute::editor::list_request {xlib jid} {
     ::xmpp::sendIQ $xlib get \
 	-query [::xmpp::xml::create list \
@@ -89,7 +128,7 @@
 proc mute::editor::subscribe_recv {xlib jid id status xml} {
     variable txts
 
-    if {$status != "OK"} {
+    if {$status != "ok"} {
 	after idle [list MessageDlg .mute_list_error -icon error \
 			 -message [::msgcat::mc "Error getting list: %s" \
 						[error_to_string $xml]] \
@@ -317,11 +356,6 @@
     }
 }
 
-::xmpp::iq::register set * $::NS(mute_editor) \
-		     [namespace current]::mute::editor::recv_set_iq
-
-
-
 ###############################################################################
 
 namespace eval mute::ancestor {
@@ -357,7 +391,6 @@
 #	-command [list [namespace current]::subscribe_recv $xlib $jid $id]
 }
 
-
 proc mute::ancestor::patch {xlib jid id patch} {
     variable txts
 
@@ -411,7 +444,7 @@
 proc mute::ancestor::unsubscribe_on_error {xlib jid id status xml} {
     variable txts
 
-    if {$status != "OK"} {
+    if {$status != "ok"} {
 	set idx [lsearch -exact $txts(subscribed,$xlib,$id) $jid]
 	set txts(subscribed,$xlib,$id) [lreplace $txts(subscribed,$xlib,$id) $idx $idx]
 	puts "REMOVE $xlib $jid"
@@ -450,10 +483,6 @@
     return ""
 }
 
-::xmpp::iq::register get * $::NS(mute_ancestor) \
-		     [namespace current]::mute::ancestor::recv_get_iq
-
-
 proc mute::ancestor::recv_set_iq {xlib from xml args} {
     ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
@@ -487,8 +516,3 @@
     return ""
 }
 
-::xmpp::iq::register set * $::NS(mute_ancestor) \
-		     [namespace current]::mute::ancestor::recv_set_iq
-
-
-

Modified: trunk/tkabber-plugins/poker/poker.tcl
===================================================================
--- trunk/tkabber-plugins/poker/poker.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/poker/poker.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -70,8 +70,6 @@
 }
 
 proc poker::load {} {
-    hook::add postload_hook [namespace current]::load_stored_theme 70
-
     hook::add roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.4
     hook::add chat_create_user_menu_hook \
@@ -91,8 +89,6 @@
 }
 
 proc poker::unload {} {
-    hook::remove postload_hook [namespace current]::load_stored_theme 70
-
     hook::remove roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.4
     hook::remove chat_create_user_menu_hook \

Modified: trunk/tkabber-plugins/renju/renju.tcl
===================================================================
--- trunk/tkabber-plugins/renju/renju.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/renju/renju.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -70,10 +70,6 @@
 }
 
 proc renju::load {} {
-    hook::add postload_hook [namespace current]::load_stored_theme 70
-
-    hook::add finload_hook [namespace current]::calc_moves 100
-
     hook::add roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.3
     hook::add chat_create_user_menu_hook \
@@ -94,10 +90,6 @@
 }
 
 proc renju::unload {} {
-    hook::remove postload_hook [namespace current]::load_stored_theme 70
-
-    hook::remove finload_hook [namespace current]::calc_moves 100
-
     hook::remove roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.3
     hook::remove chat_create_user_menu_hook \

Modified: trunk/tkabber-plugins/reversi/reversi.tcl
===================================================================
--- trunk/tkabber-plugins/reversi/reversi.tcl	2009-03-22 18:22:13 UTC (rev 1743)
+++ trunk/tkabber-plugins/reversi/reversi.tcl	2009-03-25 19:39:09 UTC (rev 1744)
@@ -62,10 +62,6 @@
 }
 
 proc reversi::load {} {
-    hook::add postload_hook [namespace current]::load_stored_theme 70
-
-    hook::add finload_hook [namespace current]::calc_moves 100
-
     hook::add roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.2
     hook::add chat_create_user_menu_hook \
@@ -86,10 +82,6 @@
 }
 
 proc reversi::unload {} {
-    hook::remove postload_hook [namespace current]::load_stored_theme 70
-
-    hook::remove finload_hook [namespace current]::calc_moves 100
-
     hook::remove roster_create_groupchat_user_menu_hook \
               [namespace current]::add_groupchat_user_menu_item 48.2
     hook::remove chat_create_user_menu_hook \



More information about the Tkabber-dev mailing list