# HG changeset patch # User Goffi # Date 1453741464 -3600 # Node ID 7a8a19e4fa6cfd5cf1bca1cdb999c4090b8c96c1 # Parent fb94f92dc7400abd543c2e49b6b482632d61ed56 plugin maildir: added an option to block intercepted normal messages: NOTE: this plugin is old and experimental, it need a good review/cleaning. diff -r fb94f92dc740 -r 7a8a19e4fa6c src/plugins/plugin_misc_maildir.py --- a/src/plugins/plugin_misc_maildir.py Mon Jan 25 17:03:45 2016 +0100 +++ b/src/plugins/plugin_misc_maildir.py Mon Jan 25 18:04:24 2016 +0100 @@ -17,27 +17,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from sat.core.i18n import _ +from sat.core.i18n import D_, _ from sat.core.constants import Const as C from sat.core.log import getLogger log = getLogger(__name__) import warnings warnings.filterwarnings('ignore', 'the MimeWriter', DeprecationWarning, 'twisted') # FIXME: to be removed, see http://twistedmatrix.com/trac/ticket/4038 -from twisted.internet import protocol -from twisted.words.protocols import jabber -from twisted.cred import portal, checkers -from twisted.mail import imap4, maildir -from email.parser import Parser +from twisted.mail import maildir import email.message import email.utils -from email.charset import Charset import os -from cStringIO import StringIO -from twisted.internet import reactor from sat.core.exceptions import ProfileUnknownError from sat.memory.persistent import PersistentBinaryDict -from zope.interface import implements PLUGIN_INFO = { "name": "Maildir Plugin", @@ -51,6 +43,9 @@ } MAILDIR_PATH = "Maildir" +CATEGORY = D_("Mail Server") +NAME = D_('Block "normal" messages propagation') +# FIXME: (very) old and (very) experimental code, need a big cleaning/review class MaildirError(Exception): @@ -58,17 +53,30 @@ class MaildirBox(object): + params = """ + + + + + + + + """.format(category_name=CATEGORY, + category_label=_(CATEGORY), + name=NAME, + label=_(NAME), + ) def __init__(self, host): log.info(_("Plugin Maildir initialization")) self.host = host + host.memory.updateParams(self.params) self.__observed = {} self.data = {} # list of profile spectific data. key = profile, value = PersistentBinaryDict where key=mailbox name, # and value is a dictionnary with the following value # - cur_idx: value of the current unique integer increment (UID) # - message_id (as returned by MaildirMailbox): a tuple of (UID, [flag1, flag2, ...]) - pList = host.memory.getProfilesList # shorter :) self.__mailboxes = {} # key: profile, value: {boxname: MailboxUser instance} #the triggers @@ -101,7 +109,7 @@ if mess_type != 'normal': return True self.accessMessageBox("INBOX", profile_key=profile).addMessage(message) - return False + return not self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile) def accessMessageBox(self, boxname, observer=None, profile_key=C.PROF_KEY_NONE): """Create and return a MailboxUser instance