NAME
Net::IMAP::Server::Connection - Connection to a client
DESCRIPTION
Maintains all of the state for a client connection to the IMAP server.
METHODS
new
Creates a new connection; the server will take care of this step.
server
Returns the Net::IMAP::Server that this connection is on.
coro
Returns the Coro process associated with this connection. For things interacting with this connection, it will probably be the current coroutine, except for interactions coming from event loops.
io_handle
Returns the IO handle that can be used to read from or write to the client.
model
Gets or sets the Net::IMAP::Server::DefaultModel or descendant associated with this connection. Note that connections which have not authenticated yet do not have a model.
auth
Gets or sets the Net::IMAP::Server::DefaultAuth or descendant associated with this connection. Note that connections which have not authenticated yet do not have an auth object.
client_id
When called with no arguments, returns a hashref of identifying information provided by the client. When key-value pairs are provided, sets the client properties. See RFC 2971.
selected [MAILBOX], [READ_ONLY]
Gets or sets the currently selected mailbox for this connection. Changing mailboxes triggers the sending of untagged notifications to the client, as well as calling "close" in Net::IMAP::Server::Mailbox and "select" in Net::IMAP::Server::Mailbox.
selected_read_only
Returns true of the currently selected mailbox has been forced into read-only mode. Note that the mailbox may be read-only for other reasons, so checking "read_only" in Net::IMAP::Server::Mailbox is suggested instead.
greeting
Sends out a one-line untagged greeting to the client.
handle_lines
The main line handling loop. Since we are using Coro, this cedes to other coroutines whenever we block, given them a chance to run. We additionally cede after handling every command.
update_timer
Updates the inactivity timer.
timer [AnyEvent watcher]
Returns the AnyEvent watcher in charge of the inactivity timer.
commands
Returns the number of client commands the connection has processed.
handle_command
Handles a single line from the client. This is not quite the same as handling a command, because of client literals and continuation commands. This also handles dispatch of client commands to Net::IMAP::Server::Command subclasses (see "class_for").
Any errors generated while running commands will cause a NO Server error
to be sent to the client -- unless the error message starts with NO
or c<BAD>, in which case it will be relayed to the client.
Returns the Net::IMAP::Server::Command instance that was run, or undef
if it was a continuation line or pending interactive command.
class_for COMMAND
Returns the package name that implements the given COMMAND
. See "add_command" in Net::IMAP::Server.
pending
If a connection has pending state, contains the callback that will receive the next line of input.
close
Shuts down this connection, also closing the model and mailboxes.
parse_command LINE
Parses the line into the tag
, command
, and options
. Returns undef if parsing fails for some reason.
is_unauth
Returns true if the connection is unauthenticated.
is_auth
Returns true if the connection is authenticated.
is_selected
Returns true if the connection has selected a mailbox.
is_encrypted
Returns true if the connection is protected by SSL or TLS.
poll
Polls the currently selected mailbox, and resets the poll timer.
force_poll
Forces a poll of the selected mailbox the next chance we get.
last_poll
Gets or sets the last time the selected mailbox was polled, in seconds since the epoch.
previous_exists
The high-water mark of how many messages the client has been told are in the mailbox.
send_untagged
Sends any untagged updates about the current mailbox to the client.
get_messages STR
Parses and returns messages fitting the given sequence range. This is on the connection and not the mailbox because messages have connection-dependent sequence numbers.
sequence MESSAGE
Returns the sequence number for the given message.
capability
Returns the current capability list for this connection, as a string. Connections not under TLS or SSL always have the LOGINDISABLED
capability, and no authentication capabilities. The "auth_class" in Net::IMAP::Server's "sasl_provides" in Net::IMAP::Server::DefaultAuth method is used to list known AUTH=
types.
log SEVERITY, MESSAGE
Defers to "log" in Net::IMAP::Server.
untagged_response STRING
Sends an untagged response to the client; a newline ia automatically appended.
out STRING
Sends the message to the client. If the client's connection has dropped, or the send fails for whatever reason, "close" the connection and then die, which is caught by "handle_lines".