diff options
author | Denis Fomin <fominde@gmail.com> | 2012-08-20 12:33:38 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2012-08-20 12:33:38 +0400 |
commit | 3781246111699d96e7cc1433efa0d185fe2c3f42 (patch) | |
tree | 6330f6bd67f3838e8275ba5d03dd2a99dc72bc7d /anti_spam/anti_spam.py | |
parent | 8c258550c2ecb132c2d3fb94bb9615b9ed566958 (diff) |
AntiSpam Plugin. Add option to disable XHTML in pm and muc
Diffstat (limited to 'anti_spam/anti_spam.py')
-rw-r--r-- | anti_spam/anti_spam.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/anti_spam/anti_spam.py b/anti_spam/anti_spam.py index e537f42..1e6dfc8 100644 --- a/anti_spam/anti_spam.py +++ b/anti_spam/anti_spam.py @@ -44,10 +44,14 @@ class AntiSpamPlugin(GajimPlugin): self.events_handlers = { 'atom-entry-received': (ged.POSTCORE, self._nec_atom_entry_received), + 'message-received': (ged.PRECORE, + self._nec_decrypted_message_received_received), } self.config_default_values = { 'block_pubsub_messages': (False, 'If True, Gajim will block incoming messages from pubsub.'), + 'disable_xhtml_muc': (False, ''), + 'disable_xhtml_pm': (False, ''), } @log_calls('AntiSpamPlugin') @@ -56,6 +60,21 @@ class AntiSpamPlugin(GajimPlugin): log.info('discarding pubdubd message') return True + @log_calls('AntiSpamPlugin') + def _nec_decrypted_message_received_received(self, obj): + if self.config['disable_xhtml_muc'] and obj.mtype == 'groupchat': + self.remove_xhtml(obj) + if self.config['disable_xhtml_pm'] and obj.gc_control and \ + obj.resource and obj.mtype == 'chat': + self.remove_xhtml(obj) + return False + + def remove_xhtml(self, obj): + html_node = obj.stanza.getTag('html') + if html_node: + obj.stanza.delChild(html_node) + + class AntiSpamPluginConfigDialog(GajimPluginConfigDialog): def init(self): self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( @@ -75,6 +94,16 @@ class AntiSpamPluginConfigDialog(GajimPluginConfigDialog): def on_run(self): self.block_pubsub_messages_checkbutton.set_active(self.plugin.config[ 'block_pubsub_messages']) + widget = self.xml.get_object('disable_xhtml_muc_checkbutton') + widget.set_active(self.plugin.config['disable_xhtml_muc']) + widget = self.xml.get_object('disable_xhtml_pm_checkbutton') + widget.set_active(self.plugin.config['disable_xhtml_pm']) def on_block_pubsub_messages_checkbutton_toggled(self, button): self.plugin.config['block_pubsub_messages'] = button.get_active() + + def on_disable_xhtml_muc_checkbutton_toggled(self, button): + self.plugin.config['disable_xhtml_muc'] = button.get_active() + + def on_disable_xhtml_pm_checkbutton_toggled(self, button): + self.plugin.config['disable_xhtml_pm'] = button.get_active() |