Check mail new logic

- use RECENT flag for search on IMAP server with write access so RECENT flag is deleted on new messages and fetch read only so SEEN flag is not set on fetched messages.
- It might work on Exchange 2003 that do not support STORE flag UNSEEN
- This change the get_mail loop so now each MailConnection type implement get_next_mail_index because logic is different from IMAP to POP3 connection.

darcs-hash:20060207213333-86b55-9c2ccf31fb9ae9e6dd454c907f3188bc6080b817.gz
This commit is contained in:
David Rousselie
2006-02-07 22:33:33 +01:00
parent e9b85d22e0
commit 505543262f
4 changed files with 85 additions and 63 deletions

View File

@@ -850,17 +850,10 @@ class MailComponent(Component):
+ "@" + account.host)
account.connect()
mail_list = account.get_mail_list()
if not mail_list or mail_list[0] == '':
num = 0
else:
num = len(mail_list)
# unseen mails checked by external client
# TODO : better test to find
if num < account.lastmail:
account.lastmail = 0
if action == mailconnection.RETRIEVE:
while account.lastmail < num:
(body, email_from) = account.get_mail(int(mail_list[account.lastmail]))
mail_index = account.get_next_mail_index(mail_list)
while mail_index is not None:
(body, email_from) = account.get_mail(mail_index)
mesg = Message(from_jid = name + "@" + \
unicode(self.jid), \
to_jid = jid, \
@@ -868,15 +861,16 @@ class MailComponent(Component):
subject = account.default_lang_class.new_mail_subject % (email_from), \
body = body)
self.stream.send(mesg)
account.lastmail += 1
account.get_next_mail_index(mail_list)
else:
body = ""
new_mail_count = 0
while account.lastmail < num:
mail_index = account.get_next_mail_index(mail_list)
while mail_index:
(tmp_body, from_email) = \
account.get_mail_summary(int(mail_list[account.lastmail]))
account.get_mail_summary(mail_index)
body += tmp_body + "\n----------------------------------\n"
account.lastmail += 1
mail_index = account.get_next_mail_index(mail_list)
new_mail_count += 1
if body != "":
mesg = Message(from_jid = name + "@" + \
@@ -915,11 +909,7 @@ class MailComponent(Component):
return
try:
account.connect()
mail_list = account.get_mail_list()
if not mail_list or mail_list[0] == '':
account.lastmail = 0
else:
account.lastmail = len(mail_list)
account.mark_all_as_read()
account.disconnect()
account.in_error = False
except Exception,e: