Mercurial > libervia-backend
comparison src/plugins/plugin_misc_maildir.py @ 916:1a759096ccbd
core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 21 Mar 2014 16:27:09 +0100 |
parents | bfabeedbf32e |
children | 301b342c697a |
comparison
equal
deleted
inserted
replaced
915:6f96ee4d8cc0 | 916:1a759096ccbd |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | |
21 from logging import debug, info, error | 22 from logging import debug, info, error |
22 import warnings | 23 import warnings |
23 warnings.filterwarnings('ignore', 'the MimeWriter', DeprecationWarning, 'twisted') # FIXME: to be removed, see http://twistedmatrix.com/trac/ticket/4038 | 24 warnings.filterwarnings('ignore', 'the MimeWriter', DeprecationWarning, 'twisted') # FIXME: to be removed, see http://twistedmatrix.com/trac/ticket/4038 |
24 from twisted.internet import protocol | 25 from twisted.internet import protocol |
25 from twisted.words.protocols.jabber import error as jab_error | 26 from twisted.words.protocols.jabber import error as jab_error |
98 if mess_type != 'normal': | 99 if mess_type != 'normal': |
99 return True | 100 return True |
100 self.accessMessageBox("INBOX", profile_key=profile).addMessage(message) | 101 self.accessMessageBox("INBOX", profile_key=profile).addMessage(message) |
101 return False | 102 return False |
102 | 103 |
103 def accessMessageBox(self, boxname, observer=None, profile_key='@DEFAULT@'): | 104 def accessMessageBox(self, boxname, observer=None, profile_key=C.PROF_KEY_NONE): |
104 """Create and return a MailboxUser instance | 105 """Create and return a MailboxUser instance |
105 @param boxname: name of the box | 106 @param boxname: name of the box |
106 @param observer: method to call when a NewMessage arrive""" | 107 @param observer: method to call when a NewMessage arrive""" |
107 profile = self.host.memory.getProfileName(profile_key) | 108 profile = self.host.memory.getProfileName(profile_key) |
108 if not profile: | 109 if not profile: |
325 mail.set_payload(e.children[0].encode('utf-8')) | 326 mail.set_payload(e.children[0].encode('utf-8')) |
326 elif e.name == "subject": | 327 elif e.name == "subject": |
327 mail['Subject'] = e.children[0].encode('utf-8') | 328 mail['Subject'] = e.children[0].encode('utf-8') |
328 return mail.as_string() | 329 return mail.as_string() |
329 | 330 |
330 def __init__(self, _maildir, name, observer=None, profile="@NONE@"): | 331 def __init__(self, _maildir, name, observer=None, profile=C.PROF_KEY_NONE): |
331 """@param _maildir: the main MaildirBox instance | 332 """@param _maildir: the main MaildirBox instance |
332 @param name: name of the mailbox | 333 @param name: name of the mailbox |
333 @param profile: real profile (ie not a profile_key) | 334 @param profile: real profile (ie not a profile_key) |
334 THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead""" | 335 THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead""" |
335 if _maildir._checkBoxReference(name, profile): | 336 if _maildir._checkBoxReference(name, profile): |