Package twisted :: Package protocols :: Module imap4 :: Class IMailbox

[frames | no frames]

## Class IMailbox

    Interface --+
                |
     IMailboxInfo --+
                    |
                   IMailbox

Method Summary
| ``addListener`(self, listener)` Add a mailbox change listener
`Deferred` | ``addMessage`(self, message, flags, date)` Add the given message to this mailbox.
| ``destroy`(self)` Called before this mailbox is deleted, permanently.
`list` or `Deferred` | ``expunge`(self)` Remove all messages flagged \Deleted.
Any iterable of two-tuples of message sequence numbers and implementors of `IMessage`. | ``fetch`(self, messages, uid)` Retrieve one or more messages.
`int` | ``getMessageCount`(self)` Return the number of messages in this mailbox.
`int` | ``getRecentCount`(self)` Return the number of messages with the 'Recent' flag.
`int` | ``getUID`(self, message)` Return the UID of a message in the mailbox
`int` | ``getUIDNext`(self)` Return the likely UID for the next message added to this mailbox.
`int` | ``getUIDValidity`(self)` Return the unique validity identifier for this mailbox.
`int` | ``getUnseenCount`(self)` Return the number of messages with the 'Unseen' flag.
`int` | ``isWriteable`(self)` Get the read/write status of the mailbox.
| ``removeListener`(self, listener)` Remove a mailbox change listener
`dict` or `Deferred` | ``requestStatus`(self, names)` Return status information about this mailbox.
`dict` or `Deferred` | ``store`(self, messages, flags, mode, uid)` Set the flags of one or more messages.
Inherited from IMailboxInfo
`list` of `str` | ``getFlags`(self)` Return the flags defined in this mailbox
`str` | ``getHierarchicalDelimiter`(self)` Get the character which delimits namespaces for in this mailbox.

Method Details

### addListener(self, listener)

Add a mailbox change listener

  Parameters:
    `listener` - An object to add to the set of those which will be notified when the contents of this mailbox change.
    (type=Any object which implements `IMailboxListener`)

### addMessage(self, message, flags=(), date=None)

Add the given message to this mailbox.

  Parameters:
    `message` - The RFC822 formatted message
    (type=A file-like object)
    `flags` - The flags to associate with this message
    (type=Any iterable of `str`)
    `date` - If specified, the date to associate with this message.
    (type=`str`)
  Returns:
    A deferred whose callback is invoked with the message id if the message is added successfully and whose errback is invoked otherwise.
    (type=`Deferred`)
  Raises:
    `ReadOnlyMailbox` - Raised if this Mailbox is not open for read-write.

### destroy(self)

Called before this mailbox is deleted, permanently.

If necessary, all resources held by this mailbox should be cleaned up here. This function _must_ set the \Noselect flag on this mailbox.

### expunge(self)

Remove all messages flagged \Deleted.

  Returns:
    The list of message sequence numbers which were deleted, or a `Deferred` whose callback will be invoked with such a list.
    (type=`list` or `Deferred`)
  Raises:
    `ReadOnlyMailbox` - Raised if this Mailbox is not open for read-write.

### fetch(self, messages, uid)

Retrieve one or more messages.

  Parameters:
    `messages` - The identifiers of messages to retrieve information about
    (type=`MessageSet`)
    `uid` - If true, the IDs specified in the query are UIDs; otherwise they are message sequence IDs.
    (type=`bool`)
  Returns:
    Any iterable of two-tuples of message sequence numbers and implementors of `IMessage`.

### getMessageCount(self)

Return the number of messages in this mailbox.

  Returns:
    `int`

### getRecentCount(self)

Return the number of messages with the 'Recent' flag.

  Returns:
    `int`

### getUID(self, message)

Return the UID of a message in the mailbox

  Parameters:
    `message` - The message sequence number
    (type=`int`)
  Returns:
    The UID of the message.
    (type=`int`)

### getUIDNext(self)

Return the likely UID for the next message added to this mailbox.

  Returns:
    `int`

### getUIDValidity(self)

Return the unique validity identifier for this mailbox.

  Returns:
    `int`

### getUnseenCount(self)

Return the number of messages with the 'Unseen' flag.

  Returns:
    `int`

### isWriteable(self)

Get the read/write status of the mailbox.

  Returns:
    A true value if write permission is allowed, a false value otherwise.
    (type=`int`)

### removeListener(self, listener)

Remove a mailbox change listener

  Parameters:
    `listener` - The object to remove from the set of listeners.
    (type=Any object previously added to and not removed from this mailbox as a listener.)
  Raises:
    `ValueError` - Raised when the given object is not a listener for this mailbox.

### requestStatus(self, names)

Return status information about this mailbox.

Mailboxes which do not intend to do any special processing to generate the return value, `statusRequestHelper` can be used to build the dictionary by calling the other interface methods which return the data for each name.

  Parameters:
    `names` - The status names to return information regarding. The possible values for each name are: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN.
    (type=Any iterable)
  Returns:
    A dictionary containing status information about the requested names is returned. If the process of looking this information up would be costly, a deferred whose callback will eventually be passed this dictionary is returned instead.
    (type=`dict` or `Deferred`)

### store(self, messages, flags, mode, uid)

Set the flags of one or more messages.

  Parameters:
    `messages` - The identifiers of the messages to set the flags of.
    (type=A MessageSet object with the list of messages requested)
    `flags` - The flags to set, unset, or add.
    (type=sequence of `str`)
    `mode` - If mode is -1, these flags should be removed from the specified messages. If mode is 1, these flags should be added to the specified messages. If mode is 0, all existing flags should be cleared and these flags should be added.
    (type=-1, 0, or 1)
    `uid` - If true, the IDs specified in the query are UIDs; otherwise they are message sequence IDs.
    (type=`bool`)
  Returns:
    A `dict` mapping message sequence numbers to sequences of `str` representing the flags set on the message after this operation has been performed, or a `Deferred` whose callback will be invoked with such a `dict`.
    (type=`dict` or `Deferred`)
  Raises:
    `ReadOnlyMailbox` - Raised if this mailbox is not open for read-write.

Generated by Epydoc 2.0 on Sat May 15 20:08:47 2004 | http://epydoc.sf.net