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()
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)
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)
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
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)
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]
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
def getSubPart(self, part): print "SUBPART:: %s" % part raise imap4.MailboxException("getSubPart not implemented")
def destroy(self): raise imap4.MailboxException("Not implemented")
def destroy(self): raise imap4.MailboxException('Not allowed')
def delete(self, path): "delete the mailbox at path" raise imap4.MailboxException("Delete not yet supported.")
def expunge(self): raise imap4.MailboxException('Not allowed')
def getUID(self, messageNum): if 0 < messageNum <= len(self.tasks): return self.tasks[messageNum - 1]["id"] raise imap4.MailboxException("Invalid message number")
def rename(self, oldname, newname): raise imap4.MailboxException('Not allowed')
def delete(self, name): raise imap4.MailboxException('Not allowed')
def create(self, pathspec): raise imap4.MailboxException('Not allowed')
def addMailbox(self, name, mbox): raise imap4.MailboxException('Not allowed')
def check_it_exists(mailboxes): if name not in mailboxes: raise imap4.MailboxException("No such mailbox: %r" % name) return True
def addMessage(self, msg, flags=(), date=None): raise imap4.MailboxException('Not allowed')
def getUIDNext(self): raise imap4.MailboxException("Not implemented")
def getSubPart(self, part): raise imap4.MailboxException("getSubPart not implemented")
def check_it_exists(mailboxes): global _mboxes _mboxes = mailboxes if name not in mailboxes: raise imap4.MailboxException("No such mailbox: %r" % name)
def delete(self, path): "delete the mailbox at path" raise imap4.MailboxException("Permission denied.")
def destroy(self): "complete remove the mailbox and all its contents" raise imap4.MailboxException("Permission denied.")
def getUID(self, messageNum): raise imap4.MailboxException("Not implemented")
def create(self, path): raise imap4.MailboxException("Create not yet supported.") "create a mailbox at path and return it"
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")
def rename(self, oldname, newname): "rename a mailbox" raise imap4.MailboxException("Rename not yet supported.")
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')