From 5775b80cec569224b93375086dd99d4f3985c219 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 17 Aug 2012 13:17:06 +0200 Subject: [PATCH 1/2] add anti-spam plugin --- anti_spam/__init__.py | 1 + anti_spam/anti_spam.py | 80 ++++++++++++++++++++++++++++++++++++++ anti_spam/config_dialog.ui | 30 ++++++++++++++ anti_spam/manifest.ini | 8 ++++ 4 files changed, 119 insertions(+) create mode 100644 anti_spam/__init__.py create mode 100644 anti_spam/anti_spam.py create mode 100644 anti_spam/config_dialog.ui create mode 100644 anti_spam/manifest.ini diff --git a/anti_spam/__init__.py b/anti_spam/__init__.py new file mode 100644 index 0000000..0256ad3 --- /dev/null +++ b/anti_spam/__init__.py @@ -0,0 +1 @@ +from anti_spam import AntiSpamPlugin diff --git a/anti_spam/anti_spam.py b/anti_spam/anti_spam.py new file mode 100644 index 0000000..e537f42 --- /dev/null +++ b/anti_spam/anti_spam.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- + +## This file is part of Gajim. +## +## Gajim is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation; version 3 only. +## +## Gajim is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Gajim. If not, see . +## + +''' +Block some incoming messages + +:author: Yann Leboulanger +:since: 16 August 2012 +:copyright: Copyright (2012) Yann Leboulanger +:license: GPLv3 +''' + +import gtk +from common import ged + +from plugins import GajimPlugin +from plugins.helpers import log, log_calls +from plugins.gui import GajimPluginConfigDialog + +class AntiSpamPlugin(GajimPlugin): + + @log_calls('AntiSpamPlugin') + def init(self): + self.description = _('Allows to block some kind of incoming messages') + self.config_dialog = AntiSpamPluginConfigDialog(self) + + self.gui_extension_points = { + } + + self.events_handlers = { + 'atom-entry-received': (ged.POSTCORE, + self._nec_atom_entry_received), + } + + self.config_default_values = { + 'block_pubsub_messages': (False, 'If True, Gajim will block incoming messages from pubsub.'), + } + + @log_calls('AntiSpamPlugin') + def _nec_atom_entry_received(self, obj): + if self.config['block_pubsub_messages']: + log.info('discarding pubdubd message') + return True + +class AntiSpamPluginConfigDialog(GajimPluginConfigDialog): + def init(self): + self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( + 'config_dialog.ui') + self.xml = gtk.Builder() + self.xml.set_translation_domain('gajim_plugins') + self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, + ['anti_spam_config_vbox']) + self.config_vbox = self.xml.get_object('anti_spam_config_vbox') + self.child.pack_start(self.config_vbox) + + self.block_pubsub_messages_checkbutton = self.xml.get_object( + 'block_pubsub_messages_checkbutton') + + self.xml.connect_signals(self) + + def on_run(self): + self.block_pubsub_messages_checkbutton.set_active(self.plugin.config[ + 'block_pubsub_messages']) + + def on_block_pubsub_messages_checkbutton_toggled(self, button): + self.plugin.config['block_pubsub_messages'] = button.get_active() diff --git a/anti_spam/config_dialog.ui b/anti_spam/config_dialog.ui new file mode 100644 index 0000000..63a57e3 --- /dev/null +++ b/anti_spam/config_dialog.ui @@ -0,0 +1,30 @@ + + + + + + + + True + 9 + vertical + 4 + + + Block pubsub messages + True + True + False + If checked, Gajim will block incoming messages from pubsub. + True + + + + False + 0 + + + + + + diff --git a/anti_spam/manifest.ini b/anti_spam/manifest.ini new file mode 100644 index 0000000..8cc7ed1 --- /dev/null +++ b/anti_spam/manifest.ini @@ -0,0 +1,8 @@ +[info] +name: Anti Spam +short_name: anti_spam +version: 0.1 +description: Block some incoming messages. +authors = Yann Leboulanger +homepage = http://trac-plugins.gajim.org/wiki/AntiSpamPlugin + From a9d3afd306028fc41432bed7218709cc337fc552 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 17 Aug 2012 13:31:16 +0200 Subject: [PATCH 2/2] add icon --- anti_spam/anti_spam.png | Bin 0 -> 821 bytes anti_spam/manifest.ini | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 anti_spam/anti_spam.png diff --git a/anti_spam/anti_spam.png b/anti_spam/anti_spam.png new file mode 100644 index 0000000000000000000000000000000000000000..2058705329df33896f053fb87f15e703fee2d202 GIT binary patch literal 821 zcmV-51Iqk~P)Vi| zK~y-)ZIexCTvZr`pYNP|=H9vUlgwxcLY&G>f0)>!AQTHiQAC@%5ru}XM5xe0R#~`d z3yru4!Igqpxaq2!Ql&0Jq2nqbSq@qWbhHTI z^#BX=)xMDjb#lg#^fbOe(izIfkCTjJ!Z1Y`gfyE?Jvli!)a$9Q5@agvx19V zZT;+c`K>pOprQ!ldFXbV`=7i|5Qd~)N+ZKV%>KGe{^)zRUNAU$a)fL;Rhh5fk-p*q zmpwR4=3tq0@c^>Ch^*YfJh{(Swd(%Jzk=`LnTd&s{|t;VT)Xz;<>~3~r(NtMOa*AI zk**~H7zbX$vaz@&L!ZC>=(96l%)Vf7{rb-Ut+~0mFK1?Mkn7KrNcbeQ#s|_v2Cv?5 zS4(elclGgUc4Yez&z(C*!rM8SQw>;0gA|k)-?0CB_ zmN<@$wRWl9YHhXJ?UV=vzP}-&{!~h(cN_c*xP=3fTa4=Y00000NkvXXu0mjfM0Jd3 literal 0 HcmV?d00001 diff --git a/anti_spam/manifest.ini b/anti_spam/manifest.ini index 8cc7ed1..b5fc4be 100644 --- a/anti_spam/manifest.ini +++ b/anti_spam/manifest.ini @@ -1,7 +1,7 @@ [info] name: Anti Spam short_name: anti_spam -version: 0.1 +version: 0.1.1 description: Block some incoming messages. authors = Yann Leboulanger homepage = http://trac-plugins.gajim.org/wiki/AntiSpamPlugin