示例#1
0
    def _actionComplete(self):
        if __debug__:
            self.printCurrentView("_actionComplete")

        if not self.testing:
            key = None

            mailMessage = self.curTransport.mailMessage

            if mailMessage.deliveryExtension.state == "FAILED":
                key = "displaySMTPSendError"
            else:
                key = "displaySMTPSendSuccess"

            utils.NotifyUIAsync(mailMessage, callable=key)

        self.curTransport = None

        """If there are messages send the next one in the Queue"""
        if len(self.pending) > 0:
            mUUID = self.pending.pop()

            if __debug__:
                self.log.warn("SMTPClient sending next message in Queue %s" % mUUID)

            """Yield to Twisted Event Loop"""
            reactor.callLater(0, self.__sendMail, mUUID)
示例#2
0
    def _commitDownloadedMail(self):
        """Commits mail to the C{Repository}.
           If there are more messages to download
           calls C{_getNextMessageSet} otherwise
           calls C{_actionCompleted} to clean up
           client references
        """
        if __debug__:
            self.printCurrentView("_commitDownloadedMail")

        self.view.commit()
        self.view.prune(1000)

        msg = constants.DOWNLOAD_MESSAGES % self.totalDownloaded

        utils.NotifyUIAsync(msg)

        """We have downloaded the last batch of messages if the
           number downloaded is less than the max.

           Add a check to make sure the account was not
           deactivated during the last fetch sequesnce.
        """
        if self.numDownloaded < self.downloadMax or not self.account.isActive:
            self._actionCompleted()

        else:
            self.numDownloaded = 0
            self.numToDownload = 0

            self._getNextMessageSet()
示例#3
0
    def __serverHasMessages(self, stat):
        if __debug__:
            self.printCurrentView("_hasMessages")

        if stat[0] == 0:
            utils.NotifyUIAsync(constants.DOWNLOAD_NO_MESSAGES)
            return self._actionCompleted()

        d = self.proto.listUID()
        d.addCallbacks(self.__checkForNewMessages, self.catchErrors)
示例#4
0
    def __statServer(self, result):
        if __debug__:
            self.printCurrentView("__statServer")

        if self.testing:
            utils.alert(constants.TEST_SUCCESS, self.account.displayName)
            return self._actionCompleted()

        utils.NotifyUIAsync(constants.DOWNLOAD_CHECK_MESSAGES)

        d = self.proto.stat()
        d.addCallbacks(self.__serverHasMessages, self.catchErrors)
示例#5
0
    def __selectInbox(self, result):
        if __debug__:
            self.printCurrentView("__selectInbox")

        if self.testing:
            utils.alert(constants.TEST_SUCCESS, self.account.displayName)
            self._actionCompleted()
            return

        utils.NotifyUIAsync(constants.DOWNLOAD_CHECK_MESSAGES)

        d = self.proto.select("INBOX")
        d.addCallbacks(self.__checkForNewMessages, self.catchErrors)
        return d
示例#6
0
    def __checkForNewMessages(self, uidList):
        if __debug__:
            self.printCurrentView("__checkForNewMessages")

        total = len(uidList)

        for i in xrange(total):
            uid = uidList[i]

            if not uid in self.account.downloadedMessageUIDS:
                self.pending.append((i, uid))

        if len(self.pending) == 0:
            utils.NotifyUIAsync(constants.DOWNLOAD_NO_MESSAGES)
            return self._actionCompleted()

        self.execInView(self._getNextMessageSet)
示例#7
0
    def __checkForNewMessages(self, msgs):
        if __debug__:
            self.printCurrentView("checkForNewMessages")

            #XXX: Need to store and compare UIDVALIDITY
        #if not msgs['UIDVALIDITY']:
        #    print "server: %s has no UUID Validity:\n%s" % (self.account.host, msgs)

        if msgs['EXISTS'] == 0:
            utils.NotifyUIAsync(constants.DOWNLOAD_NO_MESSAGES)
            return self._actionCompleted()

        if self.__getNextUID() == 0:
            msgSet = imap4.MessageSet(1, None)
        else:
            msgSet = imap4.MessageSet(self.__getNextUID(), None)

        d = self.proto.fetchFlags(msgSet, uid=True)

        d.addCallback(self.__getMessagesFlagsUID).addErrback(self.catchErrors)

        return d
示例#8
0
    def __getMessagesFlagsUID(self, msgs):
        if __debug__:
            self.printCurrentView("__getMessagesFlagsUIDS")

        nextUID = self.__getNextUID()

        for message in msgs.itervalues():
            luid = long(message['UID'])

            if luid < nextUID:
                continue

            if luid > self.lastUID:
                self.lastUID = luid

            if not "\\Deleted" in message['FLAGS']:
                self.pending.append([luid, message['FLAGS']])

        if len(self.pending) == 0:
            utils.NotifyUIAsync(constants.DOWNLOAD_NO_MESSAGES)
            return self._actionCompleted()

        self.execInView(self._getNextMessageSet)