Clonsigna: easy IMAP rev4 client library
version 0.1.1
API for package: clonsigna
Simple IMAP4rev1 client library
-Variables
+debug+: NIL variable
When true it outputs to the standard output the commands sent to the server.
-Classes
bodystructure (standard-object) class
After a bodystructure (rfc3501, rfc2822) has been parsed by PARSE-BODYSTRUCTURE function,
this class maps the parsed plist.
It is usually instantiated by MAKE-BODYSTRUCTURE function.

See CMD-FETCH-FIELDS, PARSE-BODYSTRUCTURE, MAKE-BODYSTRUCTURE
SLOTS
body reader: bodystructure-body-list writer: bodystructure-body-list
Holds the body elements in a list of STRUCTURE-ELEMENT objects.
cid reader: bodystructure-cid-list writer: bodystructure-cid-list
Holds the reference elements of a body element for inline content (as images) 
in a list of STRUCTURE-ELEMENT objects.
attachment reader: bodystructure-attachment-list writer: bodystructure-attachment-list
Holds the attachment elements in a list of STRUCTURE-ELEMENT objects.
imap-socket (standard-object) class
default-initargs: :socket nil :remote-host "127.0.0.1" :remote-port 143 :ssl-p nil
This class holds the connection to an IMAP server.
It's usually instantiated by the MAKE-IMAP function and activated by CMD-CONNECT.
SLOTS
socket reader: imap-socket-socket writer: imap-socket-socket
Holds the socket stream
remote-host reader: imap-socket-remote-host writer: imap-socket-remote-host
IMAP server address
remote-port reader: imap-socket-remote-port writer: imap-socket-remote-port
IMAP server port
crlf reader: imap-socket-crlf-p writer: imap-socket-crlf-p
UNDOCUMENTED
capabilities reader: imap-socket-capabilities writer: imap-socket-capabilities
Stores the capabilities of the imap server after connection.
messages reader: imap-socket-messages
Current messages number of the 'inbox' mailbox
uidnext reader: imap-socket-uidnext
Current uidnext of the 'inbox' mailbox
structure-element (standard-object) class
This object may hold body, reference, attachment and message elements and
should not be directly instantiated. (rfc3501#7.4.2)

See CMD-FETCH-FIELDS, PARSE-BODYSTRUCTURE, MAKE-BODYSTRUCTURE
SLOTS
mime-type reader: structure-element-mime-type writer: structure-element-mime-type
Holds the element mime-type
body-parameters reader: structure-element-body-parameters writer: structure-element-body-parameters
Holds body parameters in a plist structure (you'll usually get the :charset from here)
body-id reader: structure-element-body-id writer: structure-element-body-id
Holds the body id (rfc3501#7.4.2)
body-description reader: structure-element-body-description writer: structure-element-body-description
Holds the body description (rfc3501#7.4.2)
body-encoding reader: structure-element-body-encoding writer: structure-element-body-encoding
Holds the body encoding type (rfc3501#7.4.2, rfc2822)
section reader: structure-element-section writer: structure-element-section
Holds a list of numbers that represents the element section.
This list should then be passed to CMD-FETCH-BODY to get the current element.
-Conditions
operational-error (imap-error) class
Condition signaled on NO responses
server-error (imap-error) class
Condition signaled on BAD responses
-Functions
cmd-append imap-socket mailbox-name message &key flags date (flags nil) (date nil) standard-generic-function
Performs an IMAP APPEND (rfc3501) command.
MAILBOX-NAME The mailbox name where to append the message (can be a pathname)
MASSAGE The message string in rfc2822 format.
FLAGS A list of strings that are the flags for the message to append.
DATE The date of the message (rfc2822)

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-authenticate-plain imap-socket login password standard-generic-function
Performs an IMAP AUTHENTICATE PLAIN (rfc3501 and rfc4616) command as an
alternative to LOGIN command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-capability imap-socket standard-generic-function
Performs an IMAP CAPABILITY (rfc3501) command.
The result should usually be passed to the PARSE-CAPABILITY method that transforms it into 
a plist that will be then used to update the capabilities slot of the IMAP-SOCKET object.
A parsed capability plist is something like:
(:ACL2 ("UNION") :ACL (T) :IDLE (T) :QUOTA (T) :SORT (T) :THREAD
 ("ORDEREDSUBJECT" "REFERENCES") :NAMESPACE (T) :CHILDREN (T) :UIDPLUS (T)
 :IMAP4REV1 (T))

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-check imap-socket standard-generic-function
Performs an IMAP CHECK (rfc3501) command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-close imap-socket standard-generic-function
Performs an IMAP CLOSE (rfc3501) command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-connect imap-socket standard-generic-function
This function is requiret to connect an IMAP-SOCKET object to an IMAP server.
Depending of the passed parameter it can connect via IMAP or IMAP over ssl.
After the connection has been succeded. The capabilities slot of the parameter object passed is filled.

Return: Returns plist of capabilities got from the server like the following:
(:STARTTLS (T) :ACL2 ("UNION") :ACL (T) :IDLE (T) :QUOTA (T) :SORT (T) :THREAD
 ("ORDEREDSUBJECT" "REFERENCES") :NAMESPACE (T) :CHILDREN (T) :UIDPLUS (T)
 :IMAP4REV1 (T))
cmd-create imap-socket mailbox-name standard-generic-function
Performs an IMAP CREATE (rfc3501) command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-delete imap-socket mailbox-name standard-generic-function
Performs an IMAP DELETE (rfc3501) command.
MAILBOX-NAME parameter is the mailbox name to delete(can be a pathname).

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-examine imap-socket mailbox-name standard-generic-function
Performs an IMAP EXAMINE (rfc3501) command.
MAILBOX-NAME parameter is the mailbox name to examine(can be a pathname).

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-expunge imap-socket standard-generic-function
Performs an IMAP EXPUNGE (rfc3501) command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-fetch imap-socket sequence-number &key criteria uid-p (uid-p nil) standard-generic-function
Performs an IMAP FETCH or UID FETCH (rfc3501) command.

SEQUENCE-NUMBER Sequence set as defined in rfc3501 ir a number or a list of numbers
CRITERIA The fetching criteria as specified in rfc3501.
UID-P When not null performs an UID FETCH instead of a simple FETCH command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-fetch-body imap-socket sequence-number &key section uid-p standard-generic-function
Performs an IMAP FETCH BODY[
] or UID FETCH BODY[
] (rfc3501) command. The element result list is usually passed to the PARSE-FETCH-BODY function that decodes the reply. SEQUENCE-NUMBER Sequence set as defined in rfc3501 ir a number or a list of numbers SECTION The section to fetch that can passed in list of number form and internally transformed to the section (as described in rfc3501). UID-P When not null performs an UID FETCH instead of a simple FETCH command. Both for CMD-FETCH-BODY and for PARSE-FETCH-BODY a calls to CMD-FETCH-FIELDS -> PARSE-FETCH-FIELDS -> PARSE-BODYSTRUCTURE -> MAKE-BODYSTRUCTURE usually happen. On success returns triplet of values: 1) reply list of strings 2) result-op alway OK 3) the result-op description (what comes after OK in the IMAP reply. On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-fetch-fields imap-socket sequence-number &key fields uid-p (fields '(date from to cc bcc subject message-id in-reply-to references)) (uid-p nil) standard-generic-function
Performs an IMAP FETCH (FIELDS param) or UID FETCH (FIELDS param) (rfc3501) command.
The result is usually passed to the PARSE-FETCH-FIELDS function that produces a plist like the follofing.
((:ID 1 :UID 7 :FLAGS (SEEN) :BODYSTRUCTURE
  ("text" "plain" ("charset" "utf-8") NIL NIL "8bit" 298 11 NIL NIL NIL)
  :HEADERS
  (:MESSAGE-ID "<200808270928.m7R9SDvK008347@apache-5.foo.com>" :DATE
   "Wed, 27 Aug 2008 12:28:08 +0300" :FROM
   "\"StartCom CertMaster\" " :TO "destination@yourserver.com"
   :SUBJECT "Your Authentication Code, 27 Aug 2008 12:28")))

where :HEADERS is a plist of headers fields keywords and values where values are parsed into plain strings
(following rfc2822 specs).

The :BODYSTRUCTURE value can pe passed to PARSE-BODYSTRUCETURE function that produces a simplification of the 
bodystructure as a plist like this:
(:BODY body-list :CID cid-list :ATTACHMENT attachment-list :REPORT report-list)
each property value is in turn a plist.
After the bodystructure has been parsed, the result can be passed to function MAKE-BODYSTRUCTURE function that
instantiates a bodystructure instance.

SEQUENCE-NUMBER Sequence set as defined in rfc3501 ir a number or a list of numbers
CRITERIA The fetching criteria as specified in rfc3501.
UID-P When not null performs an UID FETCH instead of a simple FETCH command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-list imap-socket reference-name mailbox-name standard-generic-function
Performs an IMAP LIST (rfc3501) command.
The result should usually be passed to the PARSE-LIST method that transforms it into a 
list of plist like the following:

((:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Trash")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.maildir")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Drafts")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.sent-mail")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Sent"))

REFERENCE-NAME the reference mailbox name (can be a pathname).
MAILBOX-NAME the mailbox name (can be a pathname), or wildcards.

If a parameter is null, it's converted to an empty string.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-login imap-socket login password standard-generic-function
Performs an IMAP LOGIN (rfc3501) command.

On success the client will be on an authenticated state and the return will be a triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-logout imap-socket standard-generic-function
Performs an IMAP LOGOUT (rfc3501) command and so after the connection will be 
closed.

Returns a triplet of values: 
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply
cmd-namespace imap-socket standard-generic-function
Performs an IMAP NAMESPACE (rfc2342) command.
The result should usually be passed to the PARSE-NAMESPACE method that transforms it 
into a plist where keywords are
:PERSONAL :OTHERS and :SHARED
values are hashtables where key is the reference mailbox name and value is the delimiter.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-noop imap-socket standard-generic-function
Performs an IMAP NOOP (rfc3501) command.
This command is usually used as a sort of `keep alive` and should be 
periodically called by a client application.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-rename imap-socket mailbox-name new-mailbox-name standard-generic-function
Performs an IMAP RENAME (rfc3501) command.
MAILBOX-NAME parameter is the original mailbox name (can be a pathname).
NEW-MAILBOX-NAME is the new mailbox name (can be a pathname).

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-search imap-socket &key charset criteria uid-p (charset nil) (uid-p nil) standard-generic-function
Performs an IMAP SEARCH or UID SEARCH (rfc3501) command.
The result should usually be passed to the PARSE-SEARCH that returns a list of message numbers
that match the CRITERIA

CAHRSET An optional parameter specifying the charset ot the CRITERIA
CRITERIA The searching criteria as specified in rfc3501.
UID-P When not null performs an UID SEARCH instead of a simple SEARCH command.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-select imap-socket mailbox-name standard-generic-function
Performs an IMAP SELECT (rfc3501) command.
MAILBOX-NAME parameter is the mailbox name to select(can be a pathname).
The result can be parsed by the function PARSE-SELECT.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-sort imap-socket &key sort criteria uid-p charset (sort id) (criteria all) (uid-p t) (charset utf-8) standard-generic-function
Performs an IMAP SORT or UID SORT (rfc5256) command.
The result list is usually passed to the PARSE-SORT function that decodes the reply
and returns a list of ID or UID with the given sort program.

SORT is the sort program described in rfc5256.
CRITERIA is the searching criteria as specified in rfc5256.
UID-P when not nil performs an UID THREAD command.
CHARSET is the charset specification for the criteria.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-starttls imap-socket standard-generic-function
Performs an IMAP STARTTLS (rfc3501) command and performs
the negotiation with the server.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-status imap-socket mailbox-name &optional status-data-item-names standard-generic-function
Performs an IMAP STATUS (rfc3501) command.
The result should usually be passed to the PARSE-STATUS method that transforms it into
a plist that will be then used to update the status of the IMAP-SOCKET object.
A parsed status plist is something like:
(:MESSAGES 192 :RECENT 2 :UIDNEXT 6793 :UIDVALIDITY 1219826147 :UNSEEN 16)

STATUS-DATA-ITEM-NAMES List of keyword for status data item names.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-subscribe imap-socket mailbox-name standard-generic-function
Performs an IMAP SUBSCRIBE (rfc3501) command.
MAILBOX-NAME parameter is the mailbox name to subscribe to(can be a pathname).

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-thread imap-socket &key thread criteria uid-p charset (thread references) (criteria all) (uid-p t) (charset utf-8) standard-generic-function
Performs an IMAP THREAD or UID THREAD (rfc5256) command.
The result list is usually passed to the PARSE-THREAD function that decodes the reply.
The parsed result is arranged in descending order by ID or UID.

THREAD is the threading algorithm that you can find inspecting the server capabilities.
CRITERIA is the searching criteria as specified in rfc5256.
UID-P when not nil performs an UID THREAD command.
CHARSET is the charset specification for the criteria.

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
cmd-unsubscribe imap-socket mailbox-name standard-generic-function
Performs an IMAP UNSUBSCRIBE (rfc3501) command.
MAILBOX-NAME parameter is the mailbox name to unsubscribe to (can be a pathname).

On success returns triplet of values:
1) reply list of strings
2) result-op alway OK
3) the result-op description (what comes after OK in the IMAP reply.

On failure a condition of type OPERATIONAL-ERROR or SERVER-ERROR will be signaled.
ends-with end str function
Functions that checks if the given STR ends with START regardless char case
make-bodystructure bodystructure-plist function
This function creates a BODYSTRUCTURE object on a PARSE-BODYSTRUCTURE result.
See CMD-FETCH-FIELDS for more details.
make-imap &key (host 127.0.0.1) (port 143) (crlf-p t) (ssl-p nil) function
Creates an IMAP-SOCKET object

Paratmers:
HOST Remote IMAP server address
PORT Remote IMAP server port
CRLF-P IMAP line termination (it should always be true as spec. by rfc3501)
SSL-P When not null it instructs the client to connect to the server via SSL connection.
most-recents-from-parsed-thread parsed-thread function
This function returns the most recent message in a thread (by greatest ID or UID).
See PARSE-THREAD documentation for more details.
parse-bodystructure bodystructure function
This function parses a body structure returning a plist where keys are:
:BODY :CID :ATTACHMENT :REPORT
See CMD-FETCH-FIELDS form more details
parse-capability reply function
Function used to parse the result of CMD-CAPABILITY that returns a plist like the following:

(:ACL2 ("UNION") :ACL (T) :IDLE (T) :QUOTA (T) :SORT (T) :THREAD
 ("ORDEREDSUBJECT" "REFERENCES") :NAMESPACE (T) :CHILDREN (T) :UIDPLUS (T)
 :IMAP4REV1 (T))

The result should be assigned to the CAPABILITIES slot of an IMAP-SOCKET object.
parse-examine reply function
This function behaves exactly the same as PARSE-SELECT
parse-fetch-body line &key charset encoding (stream nil) function
This function parses the result of a CMD-FETCH-BODY.
It may be used to return the decoded body content string or to write it to the STREAM parameter.
See CMD-FETCH-BODY fore more info.


Parameters:
LINE a string contained the body in encoded form.
CHARSET when not null and when STREAM parameter is null it's the default charset for the output
        result. This parameter can be retrieved from the bodystructure of the message.
ENCODING the encoding format parameter. This is usually retrieved from the bodystructure
         of the message.
STREAM when not nil the parsing result is directed to this stream and functiono output
       becomes undefined.

Result:
When STREAM parameter is null, the decoded message string is returned.

See CMD-FETCH-BODY for more info.
parse-fetch-fields reply function
This function is used to parse CMD-FETCH-FIELDS result.
See CMD-FETCH-FIELDS documentation for more details.
parse-list reply function
This function is used to parse the result of CMD-LIST and produces a plist like the following:

((:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Trash")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.maildir")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Drafts")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.sent-mail")
 (:NAME-ATTRIBUTES ("HasNoChildren") :HIERARCHY-DELIMITER "." :NAME
  "INBOX.Sent"))
parse-namespace reply function
This functions is used to parse the result of CMD-NAMESPACE.
It returns a plist where keywords are
:PERSONAL :OTHERS and :SHARED
values are hashtables where key is the reference mailbox name and value is the delimiter.
parse-search reply function
This function parses the result of a CMD-SEARCH and produces a list of
ID or UID depending by the kind of the command.
parse-select reply function
This function is used to parse the result of CMD-SELECT and produces a plist like the one
produced by CMD-STATUS so a plist with keywords:
:EXISTS :RECENT :UNSEEN :PERMANENTFLAGS :UIDNEX :UIDVALIDITY :FLAGS
is generated
parse-sort reply function
This function parses the result of a CMD-SORT and produces a list of
ID or UID depending by the kind of the command.
parse-status reply function
This functions is used to parse the result of CMD-STATUS.
It returns a plist that will be then used to update the status of the IMAP-SOCKET object.
A parsed status plist is something like:
(:MESSAGES 192 :RECENT 2 :UIDNEXT 6793 :UIDVALIDITY 1219826147 :UNSEEN 16)
parse-thread reply function
This function is used to parse a CMD-THREAD result. a list of threads ID or
UID is returned in descending order.
starts-with start str function
Functions that checks if the given STR starts with START regardless char case
Generated by: CL-API