Ejemplo n.º 1
0
    def delete(self, name, force=False):
        """
        Deletes a mailbox.

        Right now it does not purge the messages, but just removes the mailbox
        name from the mailboxes list!!!

        :param name: the mailbox to be deleted
        :type name: str

        :param force: if True, it will not check for noselect flag or inferior
                      names. use with care.
        :type force: bool
        """
        name = self._parse_mailbox_name(name)

        if not name in self.mailboxes:
            raise imap4.MailboxException("No such mailbox: %r" % name)

        mbox = self.getMailbox(name)

        if force is False:
            # See if this box is flagged \Noselect
            # XXX use mbox.flags instead?
            if self.NOSELECT_FLAG in mbox.getFlags():
                # Check for hierarchically inferior mailboxes with this one
                # as part of their root.
                for others in self.mailboxes:
                    if others != name and others.startswith(name):
                        raise imap4.MailboxException, (
                            "Hierarchically inferior mailboxes "
                            "exist and \\Noselect is set")
        mbox.destroy()
        self._load_mailboxes()
Ejemplo n.º 2
0
 def addMessage(self, msg, flags=None, date=None):
     raise imap4.MailboxException("Not implemented")
     headers = Parser().parse(msg)
     try:
         uid, hostname = headers["message-id"].replace("<", "").replace(
             ">", "").split("@")
     except Exception, e:
         return defer.fail(e)
Ejemplo n.º 3
0
    def unsubscribe(self, name):
        """
        Unsubscribe from this mailbox

        :param name: name of the mailbox
        :type name: str
        """
        name = self._parse_mailbox_name(name)
        if name not in self.subscriptions:
            raise imap4.MailboxException("Not currently subscribed to %r" %
                                         name)
        self._set_subscription(name, False)
Ejemplo n.º 4
0
 def check_can_be_deleted(mbox):
     global _mboxes
     # See if this box is flagged \Noselect
     mbox_flags = mbox.getFlags()
     if MessageFlags.NOSELECT_FLAG in mbox_flags:
         # Check for hierarchically inferior mailboxes with this one
         # as part of their root.
         for others in _mboxes:
             if others != name and others.startswith(name):
                 raise imap4.MailboxException(
                     "Hierarchically inferior mailboxes "
                     "exist and \\Noselect is set")
     return mbox
Ejemplo n.º 5
0
    def getMailbox(self, name):
        """
        Returns a Mailbox with that name, without selecting it.

        :param name: name of the mailbox
        :type name: str

        :returns: a a SoledadMailbox instance
        :rtype: SoledadMailbox
        """
        name = self._parse_mailbox_name(name)

        if name not in self.mailboxes:
            raise imap4.MailboxException("No such mailbox: %r" % name)

        return SoledadMailbox(name, self._soledad, memstore=self._memstore)
Ejemplo n.º 6
0
    def delete(self, name):
        name = name.upper()
        # See if this mailbox exists at all
        mbox = self.mailboxes.get(name)
        if not mbox:
            raise imap4.MailboxException("No such mailbox")
        # See if this box is flagged \Noselect
        if r'\Noselect' in mbox.getFlags():
            # Check for hierarchically inferior mailboxes with this one
            # as part of their root.
            for others in self.mailboxes.keys():
                if others != name and others.startswith(name):
                    raise imap4.MailboxException, (
                        "Hierarchically inferior mailboxes "
                        "exist and \\Noselect is set")
        mbox.destroy()

        # iff there are no hierarchically inferior names, we will
        # delete it from our ken.
        if self._inferiorNames(name) > 1:
            del self.mailboxes[name]
Ejemplo n.º 7
0
    def _getMailbox(self, path, create=False):
        """
        Helper function to get a mailbox object at the given
        path, optionally creating it if it doesn't already exist.
        """
        if create:
            raise imap4.MailboxException("Create not yet supported.")

        if self.activesync.username in global_per_user_cache["mailbox"]:
            if path in global_per_user_cache["mailbox"][
                    self.activesync.username]:
                return global_per_user_cache["mailbox"][
                    self.activesync.username][path]
            for mbpath in global_per_user_cache["mailbox"][
                    self.activesync.username].keys():
                # case insensitive search
                if path.lower() == mbpath.lower():
                    return global_per_user_cache["mailbox"][
                        self.activesync.username][mbpath]
        d = self.activesync.add_operation(self.activesync.folder_sync)
        d.addCallback(self.listResponse)
        d.addCallback(self._getMailbox_callback, path, create)
        d.addErrback(self.listError)
        return d
Ejemplo n.º 8
0
 def getSubPart(self, part):
   print "SUBPART:: %s" % part
   raise imap4.MailboxException("getSubPart not implemented")
Ejemplo n.º 9
0
 def destroy(self):
   raise imap4.MailboxException("Not implemented")
Ejemplo n.º 10
0
 def destroy(self):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 11
0
 def delete(self, path):
     "delete the mailbox at path"
     raise imap4.MailboxException("Delete not yet supported.")
Ejemplo n.º 12
0
 def expunge(self):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 13
0
 def getUID(self, messageNum):
     if 0 < messageNum <= len(self.tasks):
         return self.tasks[messageNum - 1]["id"]
     raise imap4.MailboxException("Invalid message number")
Ejemplo n.º 14
0
 def rename(self, oldname, newname):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 15
0
 def delete(self, name):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 16
0
 def create(self, pathspec):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 17
0
 def addMailbox(self, name, mbox):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 18
0
 def check_it_exists(mailboxes):
     if name not in mailboxes:
         raise imap4.MailboxException("No such mailbox: %r" % name)
     return True
Ejemplo n.º 19
0
 def addMessage(self, msg, flags=(), date=None):
     raise imap4.MailboxException('Not allowed')
Ejemplo n.º 20
0
 def getUIDNext(self):
     raise imap4.MailboxException("Not implemented")
Ejemplo n.º 21
0
 def getSubPart(self, part):
     raise imap4.MailboxException("getSubPart not implemented")
Ejemplo n.º 22
0
 def check_it_exists(mailboxes):
     global _mboxes
     _mboxes = mailboxes
     if name not in mailboxes:
         raise imap4.MailboxException("No such mailbox: %r" % name)
Ejemplo n.º 23
0
 def delete(self, path):
     "delete the mailbox at path"
     raise imap4.MailboxException("Permission denied.")
Ejemplo n.º 24
0
 def destroy(self):
     "complete remove the mailbox and all its contents"
     raise imap4.MailboxException("Permission denied.")
Ejemplo n.º 25
0
 def getUID(self, messageNum):
   raise imap4.MailboxException("Not implemented")
Ejemplo n.º 26
0
 def create(self, path):
     raise imap4.MailboxException("Create not yet supported.")
     "create a mailbox at path and return it"
Ejemplo n.º 27
0
 def addMessage(self, msg, flags=None, date=None):
   #print "Add Message: %s :: %s" % (msg, flags)
   # passes a file handler here, need to cache fetchBodyFile so I can find the message id.
   raise imap4.MailboxException("Not implemented")
Ejemplo n.º 28
0
 def rename(self, oldname, newname):
     "rename a mailbox"
     raise imap4.MailboxException("Rename not yet supported.")
Ejemplo n.º 29
0
 def getUID(self, messageNum):
     messages = self.session.query(Message).order_by(
         Message.id.asc())[messageNum - 1:messageNum]
     if messages:
         return messages[0].id
     raise imap4.MailboxException('Message not found')