[Tkabber-dev] r266 - in trunk/plugins: . bmucx bmucx/msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Jan 5 17:07:50 MSK 2010


Author: ancestor
Date: 2010-01-05 17:07:50 +0300 (Tue, 05 Jan 2010)
New Revision: 266

Added:
   trunk/plugins/bmucx/
   trunk/plugins/bmucx/INSTALL
   trunk/plugins/bmucx/TODO
   trunk/plugins/bmucx/bmucx.tcl
   trunk/plugins/bmucx/license.terms
   trunk/plugins/bmucx/msgs/
   trunk/plugins/bmucx/msgs/ru.msg
Log:
1) New plugin - bmucx, that allows to block MUC private and public messages from users with None, Moderator, Member affiliations and roles.

Added: trunk/plugins/bmucx/INSTALL
===================================================================
--- trunk/plugins/bmucx/INSTALL	                        (rev 0)
+++ trunk/plugins/bmucx/INSTALL	2010-01-05 14:07:50 UTC (rev 266)
@@ -0,0 +1,15 @@
+To install this plugin just place its directory (bmucx) 
+into Tkabber's plugin directory. Most likely it is either 
+~/.tkabber/plugins
+or
+X:\Documents and Settings\YourUser\Application Data\Tkabber\plugins
+where X: is the drive your system is installed on.
+
+So, you'll have something like this:
+~/.tkabber/plugins/bmucx/bmucx.tcl
+or
+X:\Documents and Settings\YourUser\Application Data\Tkabber\plugins\bmucx\bmucx.tcl
+
+After that you have to restart Tkabber and go to 
+Customize -> Plugins Management and enable the plugin 
+in order to get its functionality.


Property changes on: trunk/plugins/bmucx/INSTALL
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/bmucx/TODO
===================================================================
--- trunk/plugins/bmucx/TODO	                        (rev 0)
+++ trunk/plugins/bmucx/TODO	2010-01-05 14:07:50 UTC (rev 266)
@@ -0,0 +1,7 @@
+Rearrange menu:
+
+NOW: Topic Menu	-Block private messages -...
+		-Block public messages -...
+
+TODO: Topic Menu -Blocking messages -Block public messages -...
+				    -Block private messages -...
\ No newline at end of file


Property changes on: trunk/plugins/bmucx/TODO
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/bmucx/bmucx.tcl
===================================================================
--- trunk/plugins/bmucx/bmucx.tcl	                        (rev 0)
+++ trunk/plugins/bmucx/bmucx.tcl	2010-01-05 14:07:50 UTC (rev 266)
@@ -0,0 +1,188 @@
+#Initial code: Block MUC private plugin 13-07-2009 (Jet <megaxbit at xmpp.ru>)
+#Modifications: Block MUC messages plugin 05-01-2010 (ancestor <ancestor at jabber.org>)
+#Allows to block MUC private and public messages from users with None, Moderator, Member affiliations and roles.
+
+namespace eval bmucx {
+	::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    if {![::plugins::is_registered bmucx]} {
+	::plugins::register bmucx \
+			    -namespace [namespace current] \
+			    -source [info script] \
+			    -description [::msgcat::mc "Block MUC messages."] \
+			    -loadcommand [namespace code load] \
+			    -unloadcommand [namespace code unload]
+	return
+    }
+	
+	custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+	custom::defgroup bmuch bmuch -group Plugins -type hidden
+	custom::defgroup bmuchpr bmuchpr -group Plugins -type hidden
+	custom::defvar bmuc_list "" [::msgcat::mc "MUC List."] -type string -group bmuch
+	custom::defvar moders_list "" [::msgcat::mc "Moders List."] -type string -group bmuch
+	custom::defvar members_list "" [::msgcat::mc "Members List."] -type string -group bmuch	
+	custom::defvar bmuc_list_priv "" [::msgcat::mc "MUC Private List."] -type string -group bmuchpr
+	custom::defvar moders_list_priv "" [::msgcat::mc "Moders Private List."] -type string -group bmuchpr
+	custom::defvar members_list_priv "" [::msgcat::mc "Members Private List."] -type string -group bmuchpr
+}
+
+########################################################################################
+
+proc bmucx::refresh_list_priv {} {
+	variable bmuc_list_priv
+	variable moders_list_priv
+	variable members_list_priv
+	set bmuc_list_priv [array get ::blockvar_priv]
+	set moders_list_priv [array get ::blockvar_moders_priv]	
+	set members_list_priv [array get ::blockvar_members_priv]
+}
+
+proc bmucx::refresh_list {} {
+	variable bmuc_list
+	variable moders_list
+	variable members_list
+	set bmuc_list [array get ::blockvar]
+	set moders_list [array get ::blockvar_moders]	
+	set members_list [array get ::blockvar_members]
+}
+
+########################################################################################
+
+proc bmucx::load_list_priv {} {
+	variable bmuc_list_priv
+	variable moders_list_priv
+	variable members_list_priv
+	array set ::blockvar_priv $bmuc_list_priv
+	array set ::blockvar_moders_priv $moders_list_priv
+	array set ::blockvar_members_priv $members_list_priv
+}
+
+proc bmucx::load_list {} {
+	variable bmuc_list
+	variable moders_list
+	variable members_list
+	array set ::blockvar $bmuc_list
+	array set ::blockvar_moders $moders_list
+	array set ::blockvar_members $members_list
+}
+
+########################################################################################
+
+proc bmucx::add_pub_menu {m xlib jid} {
+	set bm [menu $m.bmuc -tearoff 0]
+	$bm add checkbutton -label [::msgcat::mc "On"] \
+		-indicatoron 1 -variable ::blockvar($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list
+
+	set mstate normal
+	if {!$::blockvar($jid)} {set mstate disabled}
+	$bm add separator
+
+	$bm add checkbutton -label [::msgcat::mc "Block message from moderators"] \
+		-indicatoron 1 -variable ::blockvar_moders($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list -state $mstate
+	$bm add checkbutton -label [::msgcat::mc "Block message from members"] \
+		-indicatoron 1 -variable ::blockvar_members($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list -state $mstate		
+		
+	$m add cascade -label [::msgcat::mc "Block public messages"] -menu $bm
+	$m add separator
+}
+
+proc bmucx::add_priv_menu {mpr xlib jid} {
+	set bmpr [menu $mpr.bmucpr -tearoff 0]
+	$bmpr add checkbutton -label [::msgcat::mc "On"] \
+		-indicatoron 1 -variable ::blockvar_priv($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list_priv
+
+	set mstatepriv normal
+	if {!$::blockvar_priv($jid)} {set mstatepriv disabled}
+	$bmpr add separator
+
+	$bmpr add checkbutton -label [::msgcat::mc "Block message from moderators"] \
+		-indicatoron 1 -variable ::blockvar_moders_priv($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list_priv -state $mstatepriv
+	$bmpr add checkbutton -label [::msgcat::mc "Block message from members"] \
+		-indicatoron 1 -variable ::blockvar_members_priv($jid) -offvalue 0 -onvalue 1 \
+		-command [namespace current]::refresh_list_priv -state $mstatepriv		
+	
+	$mpr add cascade -label [::msgcat::mc "Block private messages"] -menu $bmpr
+}
+
+########################################################################################
+
+proc bmucx::block_user_priv {xlib from} {
+	set jid [::xmpp::jid::stripResource $from]
+	set chatid [chat::chatid $xlib $jid]
+	if {[chat::is_groupchat $chatid]} {
+		if {[info exists ::blockvar_priv($jid)] && $::blockvar_priv($jid)} {
+			if {[catch {set role $::muc::users(role,$xlib,$from)}]} {return 0}
+			if {$role == "moderator"} {
+				if {[info exists ::blockvar_moders_priv($jid)] && $::blockvar_moders_priv($jid)} {
+					return 1
+				} else {return 0}
+			}			
+			if {[catch {set aff $::muc::users(affiliation,$xlib,$from)}]} {return 0}
+			if {$aff == "member"} {
+				if {[info exists ::blockvar_members_priv($jid)] && $::blockvar_members_priv($jid)} {
+					return 1
+				} else {return 0}	
+			}			
+			return 1
+		} else {return 0}
+	} else {return 0}	
+}
+
+proc bmucx::block_user {xlib from} {
+	set jid [::xmpp::jid::stripResource $from]
+	set chatid [chat::chatid $xlib $jid]
+	if {[chat::is_groupchat $chatid]} {
+		if {[info exists ::blockvar($jid)] && $::blockvar($jid)} {
+			if {[catch {set role $::muc::users(role,$xlib,$from)}]} {return 0}
+			if {$role == "moderator"} {
+				if {[info exists ::blockvar_moders($jid)] && $::blockvar_moders($jid)} {
+					return 1
+				} else {return 0}
+			}			
+			if {[catch {set aff $::muc::users(affiliation,$xlib,$from)}]} {return 0}
+			if {$aff == "member"} {
+				if {[info exists ::blockvar_members($jid)] && $::blockvar_members($jid)} {
+					return 1
+				} else {return 0}	
+			}			
+			return 1
+		} else {return 0}
+	} else {return 0}	
+}
+
+proc bmucx::block_pub_messages {xlib from id type is_subject subject body err thread priority x} {
+	if {$type == "groupchat" && [[namespace current]::block_user $xlib $from]} {
+		return stop	
+	}
+}
+
+proc bmucx::block_priv_messages {xlib from id type is_subject subject body err thread priority x} {
+	if {$type != "groupchat" && [[namespace current]::block_user_priv $xlib $from]} {
+		return stop	
+	}
+}
+
+########################################################################################
+
+proc bmucx::load {} {
+	hook::add finload_hook [namespace current]::load_list
+	hook::add finload_hook [namespace current]::load_list_priv
+	hook::add chat_create_conference_menu_hook [namespace current]::add_pub_menu 0
+	hook::add chat_create_conference_menu_hook [namespace current]::add_priv_menu 0
+	hook::add process_message_hook [namespace current]::block_pub_messages 40
+	hook::add process_message_hook [namespace current]::block_priv_messages 40
+}
+
+proc bmucx::unload {} {
+	hook::remove finload_hook [namespace current]::load_list
+	hook::remove finload_hook [namespace current]::load_list_priv
+	hook::add chat_create_conference_menu_hook [namespace current]::add_pub_menu 0
+	hook::add chat_create_conference_menu_hook [namespace current]::add_priv_menu 0
+	hook::add process_message_hook [namespace current]::block_pub_messages 40
+	hook::add process_message_hook [namespace current]::block_priv_messages 40
+}
\ No newline at end of file

Added: trunk/plugins/bmucx/license.terms
===================================================================
--- trunk/plugins/bmucx/license.terms	                        (rev 0)
+++ trunk/plugins/bmucx/license.terms	2010-01-05 14:07:50 UTC (rev 266)
@@ -0,0 +1,20 @@
+Initial Copyright And Idea (c) 2009 Jet <xmpp:megaxbit at xmpp.ru>
+Modifications (c) 2010 ancestor <xmpp:ancestor at jabber.org>
+
+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.


Property changes on: trunk/plugins/bmucx/license.terms
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/bmucx/msgs/ru.msg
===================================================================
--- trunk/plugins/bmucx/msgs/ru.msg	                        (rev 0)
+++ trunk/plugins/bmucx/msgs/ru.msg	2010-01-05 14:07:50 UTC (rev 266)
@@ -0,0 +1,6 @@
+::msgcat::mcset ru "Block MUC messages." "Блокировка сообщений конференций."
+::msgcat::mcset ru "Block public messages" "Блокировать групповые сообщения"
+::msgcat::mcset ru "Block private messages" "Блокировать приватные сообщения"
+::msgcat::mcset ru "Block message from moderators" "Блокировать сообщения от модераторов"
+::msgcat::mcset ru "Block message from members" "Блокировать сообщения от постоянных участников"
+::msgcat::mcset ru "On" "Включено"
\ No newline at end of file


Property changes on: trunk/plugins/bmucx/msgs/ru.msg
___________________________________________________________________
Added: svn:executable
   + *



More information about the Tkabber-dev mailing list