Commit 7ac96345 authored by Boris Kocherov's avatar Boris Kocherov Committed by Arnaud Fontaine

EmailReader compatibility with various ImapServers is improved.

* imap.mail.ru and imap.gmail.com use '/' as a delimiter.
* gmail.com does not support '( ALL )', use 'ALL' instead.
* parse multiple flags.
parent ad309c80
...@@ -153,7 +153,7 @@ class IMAPSServer(MailServer): ...@@ -153,7 +153,7 @@ class IMAPSServer(MailServer):
message_folder -- the name of the folder to ingest messages from message_folder -- the name of the folder to ingest messages from
""" """
self._selectMessageFolder(message_folder) self._selectMessageFolder(message_folder)
query = "( ALL )" query = "ALL"
response, message_id_list = self.server.uid('search', None, query) # XXX - reponse not taken into account response, message_id_list = self.server.uid('search', None, query) # XXX - reponse not taken into account
result = message_id_list[0].split() result = message_id_list[0].split()
result.reverse() # Download the latest first result.reverse() # Download the latest first
...@@ -171,13 +171,13 @@ class IMAPSServer(MailServer): ...@@ -171,13 +171,13 @@ class IMAPSServer(MailServer):
result = [] result = []
response, folder_list = self.server.list() # XXX - reponse not taken into account response, folder_list = self.server.list() # XXX - reponse not taken into account
for folder in folder_list: for folder in folder_list:
if folder is not None: if folder is not None:
folder_definition_list = folder.split(' "." ')
# XXX - Here we consider that
# strings are of the form '(\\HasChildren) "." "INBOX.Business.OpenBrick.Prospects"' # strings are of the form '(\\HasChildren) "." "INBOX.Business.OpenBrick.Prospects"'
# but is this really the generic case - review IMAP protocol # folder_flags delimeter folder
folder_type, folder_name = folder_definition_list folder_flags, folder_name = folder.split(') "', 1)
folder_name = folder_name[1:-1] folder_flags = folder_flags.strip('(')
folder_delimiter, folder_name = folder.split('" ', 1)
folder_name = folder_name.strip('"')
result.append(folder_name) result.append(folder_name)
return result return result
...@@ -434,7 +434,7 @@ class EmailReader(ExternalSource): ...@@ -434,7 +434,7 @@ class EmailReader(ExternalSource):
""" """
if message_folder is None: if message_folder is None:
return str(uid) return str(uid)
return "%s-%s" % (message_folder, uid) # Can this be configurable, based on what ? date? return "%s-%s" % (message_folder.replace('/','.'), uid) # Can this be configurable, based on what ? date?
security.declareProtected(Permissions.AccessContentsInformation, 'getMessageFolderList') security.declareProtected(Permissions.AccessContentsInformation, 'getMessageFolderList')
def getMessageFolderList(self): def getMessageFolderList(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment