From 2596ea291bc4a4e2b81e87cd2a0ee5f7a629514e Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 8 Jan 2013 00:46:38 +0100 Subject: [PATCH] core, plugin imap, plugin smtp: fixed SMTP/IMAP integration. /!\ Profile need to be connected for IMAP server to work (will change in the future) --- src/memory/memory.py | 3 +++ src/plugins/plugin_misc_imap.py | 9 ++++----- src/plugins/plugin_misc_smtp.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/memory/memory.py b/src/memory/memory.py index 5bc6311a..3a2582b5 100644 --- a/src/memory/memory.py +++ b/src/memory/memory.py @@ -844,6 +844,9 @@ class Memory: def getParamA(self, name, category, attr="value", profile_key='@DEFAULT@'): return self.params.getParamA(name, category, attr, profile_key) + def asyncGetParamA(self, name, category, attr="value", profile_key='@DEFAULT@'): + return self.params.asyncGetParamA(name, category, attr, profile_key) + def asyncGetStringParamA(self, name, category, attr="value", profile_key='@DEFAULT@'): return self.params.asyncGetStringParamA(name, category, attr, profile_key) diff --git a/src/plugins/plugin_misc_imap.py b/src/plugins/plugin_misc_imap.py index 4709c0cf..983e81b8 100755 --- a/src/plugins/plugin_misc_imap.py +++ b/src/plugins/plugin_misc_imap.py @@ -426,11 +426,10 @@ class SatProfileCredentialChecker: profiles = self.host.memory.getProfilesList() if not credentials.username in profiles: return defer.fail(cred_error.UnauthorizedLogin()) - password = self.host.memory.getParamA("Password", "Connection", profile_key=credentials.username) - return defer.maybeDeferred( - credentials.checkPassword, - password).addCallback( - self._cbPasswordMatch, credentials.username) + d = self.host.memory.asyncGetParamA("Password", "Connection", profile_key=credentials.username) + d.addCallback(lambda password: credentials.checkPassword(password)) + d.addCallback(self._cbPasswordMatch, credentials.username) + return d class ImapServerFactory(protocol.ServerFactory): protocol = imap4.IMAP4Server diff --git a/src/plugins/plugin_misc_smtp.py b/src/plugins/plugin_misc_smtp.py index c3a59119..eae325fa 100755 --- a/src/plugins/plugin_misc_smtp.py +++ b/src/plugins/plugin_misc_smtp.py @@ -91,7 +91,7 @@ class SatSmtpMessage: mail = Parser().parsestr("\n".join(self.message)) try: self.host.sendMessage(parseaddr(mail['to'].decode('utf-8','replace'))[1], mail.get_payload().decode('utf-8','replace'), #TODO: manage other charsets - subject=mail['subject'].decode('utf-8','replace'), type='normal', profile_key=self.profile) + subject=mail['subject'].decode('utf-8','replace'), mess_type='normal', profile_key=self.profile) except: exc_type, exc_value, exc_traceback = sys.exc_info() error(_("Can't send message: %s") % exc_value) #The email is invalid or incorreclty parsed