changeset 574:89f9a50ce7bf

core, plugin imap, plugin smtp: fixed SMTP/IMAP integration. /!\ Profile need to be connected for IMAP server to work (will change in the future)
author Goffi <goffi@goffi.org>
date Tue, 08 Jan 2013 00:46:38 +0100 (2013-01-07)
parents db7a03a33612
children f5ab27e0ff4c
files src/memory/memory.py src/plugins/plugin_misc_imap.py src/plugins/plugin_misc_smtp.py
diffstat 3 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/memory.py	Mon Jan 07 23:54:17 2013 +0100
+++ b/src/memory/memory.py	Tue Jan 08 00:46:38 2013 +0100
@@ -844,6 +844,9 @@
     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)
     
--- a/src/plugins/plugin_misc_imap.py	Mon Jan 07 23:54:17 2013 +0100
+++ b/src/plugins/plugin_misc_imap.py	Tue Jan 08 00:46:38 2013 +0100
@@ -426,11 +426,10 @@
         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
--- a/src/plugins/plugin_misc_smtp.py	Mon Jan 07 23:54:17 2013 +0100
+++ b/src/plugins/plugin_misc_smtp.py	Tue Jan 08 00:46:38 2013 +0100
@@ -91,7 +91,7 @@
         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