From 8e9a420517cebe1650e37b6944dfaf1b98fddcaf Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Tue, 7 Feb 2006 23:15:28 +0100 Subject: [PATCH] POP3 exception and IMAP infinite loop corrected darcs-hash:20060207221528-86b55-fac5a34889bd37751ad3f6f3f4b2f423360535ec.gz --- jabber/component.py | 5 +++-- jabber/mailconnection.py | 10 +++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/jabber/component.py b/jabber/component.py index 50e4f62..913cd53 100644 --- a/jabber/component.py +++ b/jabber/component.py @@ -836,7 +836,7 @@ class MailComponent(Component): """ Check mail account """ def check_mail(self, jid, name): - self.__logger.debug("CHECK_MAIL " + unicode(jid) + " " + name) + self.__logger.debug("\nCHECK_MAIL " + unicode(jid) + " " + name) account = self.__storage[(jid, name)] action = account.action @@ -861,7 +861,7 @@ class MailComponent(Component): subject = account.default_lang_class.new_mail_subject % (email_from), \ body = body) self.stream.send(mesg) - account.get_next_mail_index(mail_list) + mail_index = account.get_next_mail_index(mail_list) else: body = "" new_mail_count = 0 @@ -882,6 +882,7 @@ class MailComponent(Component): self.stream.send(mesg) account.disconnect() account.in_error = False + self.__logger.debug("\nCHECK_MAIL ends " + unicode(jid) + " " + name) except Exception,e: if account.in_error == False: account.in_error = True diff --git a/jabber/mailconnection.py b/jabber/mailconnection.py index c7ba8f7..6ebf4e5 100644 --- a/jabber/mailconnection.py +++ b/jabber/mailconnection.py @@ -445,12 +445,8 @@ class POP3Connection(MailConnection): def get_mail_list(self): POP3Connection._logger.debug("Getting mail list") count, size = self.connection.stat() - result = [str(i) for i in range(1, count + 1)] - if not result or result[0] == '': - self.__nb_mail = 0 - else: - self.__nb_mail = len(result) - return result + self.__nb_mail = count + return [str(i) for i in range(1, count + 1)] def get_mail(self, index): POP3Connection._logger.debug("Getting mail " + str(index)) @@ -471,7 +467,7 @@ class POP3Connection(MailConnection): return None if self.__nb_mail < self.__lastmail: self.__lastmail = 0 - result = self.__lastmail + result = int(mail_list[self.__lastmail]) self.__lastmail += 1 return result