Net::IMAP::Server::Mailbox - A user's view of a mailbox
This class encapsulates the view of messages in a mailbox. You may wish to subclass this class in order to source our messages from, say, a database.
Sets up basic properties of the mailbox:
This default mailbox implementation simply returns an empty mailbox. Subclasses will probably wish to override this method.
Gets or sets the name of the mailbox. This includes a workaround for Zimbra, which doesn't understand mailbox names with colons in them -- so we substitute dashes.
Called when the server wishes the mailbox to update its state. By default, does nothing. Subclasses will probably wish to override this method.
Adds the given Net::IMAP::Server::Message
MESSAGE to the mailbox,
setting its "sequence" in Net::IMAP::Server::Message and "mailbox" in Net::IMAP::Server::Message.
"uid" in Net::IMAP::Server::Message is set to "uidnext" if the message does not already have a
Creates a mailbox under this mailbox, of the same class as this mailbox is. Any arguments are passed to "new". Returns the newly added subfolder, or undef if a folder with that name already exists.
Identical to "add_child". Should return false if the create is denied or fails.
Reparents this mailbox to be a child of the given Net::IMAP::Server::Mailbox
with the given
Should return 0 if the reparenting is denied or fails.
Deletes this mailbox, removing it from its parent's list of children. Should return false if the deletion is denied or fails.
Expunges messages marked as
If an arrayref of message sequence numbers is provided,
only expunges message from that set.
which should be a string containing the message.
Returns false is the append is denied or fails.
Called when the client selects a different mailbox, or when the client's connection closes. By default, does nothing.
Returns the path separator. Note that only the path separator of the root mailbox matters. Defaults to a forward slash.
If the function returns is undef, the server supports only flat mailboxes (i.e. no child mailboxes are allowed).
Returns the full path to this mailbox.
This value is cached aggressively on a per-connection basis; passing
purge flushes this cache,
if the path name has changed.
Returns the list of flags that this mailbox supports.
Returns true if the client is allowed to set the given flag in this mailbox; this simply scans "flags" to check.
Returns the number of messages in this mailbox. Observing this also sets the "high water mark" for notifying the client of messages added.
Returns the number of messages which have the
\Recent flag set.
Returns the sequence number of the first message which does not have the
\Seen flag set.
Returns 0 if all messages have been marked as
Returns the number of messages which do not have the
\Seen flag set.
Returns the flags which will be stored permanently for this mailbox; defaults to the same set as "flags" returns.
Called when the clients requests a status update (via Net::IMAP::Server::Command::Status).
TYPES should be the types of information requested,
chosen from this list:
The number of messages in the mailbox (via "exists")
The number of messages marked as
\Recent (via "recent")
The number of messages not marked as
\Seen (via "unseen")
/uidvalidity of the mailbox.
/uidnext of the mailbox.
Returns true if this mailbox is read-only.
the value of this depends on if the mailbox was selected using
SELECT (see Net::IMAP::Server::Command::Select and "selected_read_only" in Net::IMAP::Server::Connection)
Called when the mailbox is selected; by default does nothing. Note that this could be called a a result of either a SELECT or an EXAMINE.
Returns true if this mailbox is the mailbox selected by the current Net::IMAP::Server::Connection.
This method exists to choose the most apppriate strategy to take the intersection of (uids asked for) n (uids we have), by examining the cardinality of each set, and iterating over the smaller of the two. This is particularly important, as many clients try to fetch UIDs 1:*, which will exhaust memory if the naive approach is taken, and there is one message with UID 100_000_000.
Parses and returns messages fitting the given UID range.
Parses and returns messages fitting the given sequence range. Note that since sequence numbers are connection-dependent, this simply passes the buck to "Net::IMAP::Server::Connection/get_messages".
Called before the model's children are listed to the client. This is the right place to hook into for mailboxes whose children shift with time.
Called before the mailbox is destroyed; this deals with cleaning up the several circular references involved. In turn, it calls "prep_for_destroy" on all child mailboxes, as well as all messages it has.