def _cbGetChandlerFolderStatus(self, result, status):
        try:
            # results:
            #   0: Tuple of flags on the folder ie. ('\\Marked', '\\HasChildren')
            #   1: The folder delimiter
            #   2: the folder name
            folderFlags, folderDelim, folderName = result[0]

            # Assign the lowercase flags back to
            # the folderFlags variable. This
            # allows a case insensitive compare
            # of flags such as \\NoInferiors.
            folderFlags = map(str.lower, folderFlags)

        except:
            # This error should never be raised but a
            # safeguard is put in place just in case.
            # Raising an IMAPException will result in
            # a clearer error message to the user
            # than just letting the index out of range
            # error be raised and show to the user.
            return self.proto._raiseException(
                errors.IMAPException(constants.INBOX_LIST_ERROR))

        if not ("\\noinferiors" in folderFlags or \
           "\\noselect" in folderFlags or \
           folderDelim is None or \
           folderDelim.lower() == "nil"):
            # The folder can be created under the INBOX
            for key in constants.ALL_IMAP_FOLDERS:
                status[key][0] = u"INBOX%s%s" % (folderDelim, key)

        return self._getListingDeferredList(constants.ALL_IMAP_FOLDERS, 0,
                                            status)
Exemple #2
0
 def timeoutConnection(self):
     """Called by C{policies.TimeoutMixin} base class.
        The method generates an C{IMAPException} and
        forward to delegate.catchErrors
     """
     exc = errors.IMAPException(errors.STR_TIMEOUT_ERROR)
     """We have timed out so do not send any more commands to
        the server just disconnect """
     self.factory.timedOut = True
     self.delegate.catchErrors(exc)
Exemple #3
0
    def __getCapabilities(self, caps):
        if self.factory.useTLS:
            """The Twisted IMAP4Client will check to make sure the server can STARTTLS
               and raise an error if it can not"""
            d = self.startTLS(self.transport.contextFactory.getContext())

            d.addCallbacks(lambda _: self.delegate.loginClient(), \
                                     self.delegate.catchErrors)
            return d

        if 'LOGINDISABLED' in caps:
            e = errors.IMAPException(constants.DOWNLOAD_REQUIRES_TLS)
            self.delegate.catchErrors(e)

        else:
            """Remove the STARTTLS from capabilities"""
            self._capCache = utils.disableTwistedTLS(caps)
            self.delegate.loginClient()
    def _getCapabilities(self, caps):
        if __debug__:
            trace("_getCapabilities")

        if self.factory.useTLS:
            # The Twisted IMAP4Client will check to make sure the server can STARTTLS
            # and raise an error if it can not
            d = self.startTLS(self.transport.contextFactory.getContext())

            d.addCallback(lambda _: self.delegate.loginClient())
            d.addErrback(self.delegate.catchErrors)
            return None

        if 'LOGINDISABLED' in caps:
            return self._raiseException(
                errors.IMAPException(constants.MAIL_PROTOCOL_REQUIRES_TLS))

        else:
            # Remove the STARTTLS from capabilities
            self._capCache = disableTwistedTLS(caps)
            self.delegate.loginClient()
    def _getMail(self, result):
        if __debug__:
            trace("_getMail")

        if self.cancel:
            return self._actionCompleted()

        if self.account.folders.isEmpty():
            # The account is missing the default
            # Inbox IMAPFolder.
            err = constants.IMAP_INBOX_MISSING % \
                          {'accountName': self.account.displayName}

            return self.proto._raiseException(errors.IMAPException(err))

        self.vars = FolderVars()
        self.vars.folderItem = self.account.folders.first()

        d = self.proto.select(self.vars.folderItem.folderName).addCallback(
            self._checkForNewMessages).addErrback(self.catchErrors)

        return None