Next: , Previous: Folder, Up: libmailbox


3.1.2 Mailbox

     /* Prefix mu_mailbox_ is reserved. */
     #include <mailutils/mailbox.h>
— Data Type: mu_mailbox_t

The mu_mailbox_t object is used to hold information and it is an opaque data structure to the user. Functions are provided to retrieve information from the data structure.

                                  mu_mailbox_t               mu_url_t
       -/var/mail-    +---//--->/------------------\   +-->/-----------\
      (  alain   )    |         |  mu_url_t      *-|---+   |  port     |
       ----------     |         |------------------+       |  hostname |
      (  jakob *-)----+         |  mu_observer_t *-|       |  file     |
       ----------               |------------------+       |  ...      |
      (  jeff    )              |  mu_stream_t     |       \-----------/
       ----------               |------------------|
      (  sean    )              |  mu_locker_t     |
       ----------               |------------------|
                                |  mu_message_t(1) |
                                |------------------|
                                |  mu_message_t(2) |
                                |  ......          |
                                |  mu_message_t(n) |
                                \------------------/
— Function: int mu_mailbox_create (mu_mailbox_t *mbox, const char *name)

The function mu_mailbox_create allocates and initializes mbox. The concrete mailbox type instantiate is based on the scheme of the url name.

The return value is 0 on success and a code number on error conditions:

MU_ERR_OUT_PTR_NULL
The pointer mbox supplied is NULL.
MU_ERR_NO_HANDLER
The url name supplied is invalid or not supported.
EINVAL
ENOMEM
Not enough memory to allocate resources.

— Function: int mu_mailbox_create_default (mu_mailbox_t *mbox, const char *name)

Create a mailbox with mu_mailbox_create() based on the environment variable MAIL or the string formed by _PATH_MAILDIR/user" or LOGNAME if user is null,

— Function: void mu_mailbox_destroy (mu_mailbox_t *mbox)

Destroys and releases resources held by mbox.

— Function: int mu_mailbox_open (mu_mailbox_t mbox, int flag)

A connection is open, if no stream was provided, a stream is created based on the mbox type. The flag can be OR'ed. See stream_create() for flag's description.

The return value is 0 on success and a code number on error conditions:

EAGAIN
EINPROGRESS
Operation in progress.
EBUSY
Resource busy.
MU_ERROR_INVALID_PARAMETER
mbox is NULL or flag is invalid.
ENOMEM
Not enough memory.

— Function: int mu_mailbox_close (mu_mailbox_t mbox)

The stream attach to mbox is closed.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_flush (mu_mailbox_t mbox, int expunge)
— Function: int mu_mailbox_get_folder (mu_mailbox_t mbox, folder_t *folder)

Get the folder.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_set_folder (mu_mailbox_t mbox, mu_folder_t folder)
— Function: int mu_mailbox_uidvalidity (mu_mailbox_t mbox, unsigned long *number);

Give the uid validity of mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_uidnext (mu_mailbox_t mbox, size_t *number);

Give the next predicted uid for mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_get_message (mu_mailbox_t mbox, size_t msgno, mu_message_t *message)

Retrieve message number msgno, message is allocated and initialized.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL or msgno is invalid.
ENOMEM
Not enough memory.

— Function: int mu_mailbox_append_message (mu_mailbox_t mbox, mu_message_t message)

The message is appended to the mailbox mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL or message is invalid.

— Function: int mu_mailbox_messages_count (mu_mailbox_t mbox, size_t *number);

Give the number of messages in mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_messages_recent (mu_mailbox_t mbox, size_t *number);

Give the number of recent messages in mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_message_unseen (mu_mailbox_t mbox, size_t *number);

Give the number of first unseen message in mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_expunge (mu_mailbox_t mbox)

All messages marked for deletion are removed.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_save_attributes (mu_mailbox_t mbox)
— Function: int mu_mailbox_get_size (mu_mailbox_t mbox, mu_off_t *size)

Gives the mbox size.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_is_updated (mu_mailbox_t mbox)
— Function: int mu_mailbox_scan (mu_mailbox_t mbox, size_t msgno, size_t *count);

Scan the mailbox for new messages starting at message msgno.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.
ENOMEM
Not enough memory.

— Function: int mu_mailbox_get_stream (mu_mailbox_t mbox, mu_stream_t *stream)

The mailbox stream is put in stream.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is invalid or stream is NULL.

— Function: int mu_mailbox_set_stream (mu_mailbox_t mbox, mu_stream_t stream)

Set the stream connection to use for the mailbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox or stream is NULL.

— Function: int mu_mailbox_get_locker (mu_mailbox_t mbox, mu_locker_t *locker)

Get the mu_locker_t object.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_set_locker (mu_mailbox_t mbox, mu_locker_t locker)

Set the type of locking done by the mbox.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_get_property (mu_mailbox_t mbox, mu_property_t *property)

Get the property object. The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.
ENOMEM

— Function: int mu_mailbox_get_url (mu_mailbox_t mbox, mu_url_t *url)

Gives the constructed url.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.

— Function: int mu_mailbox_has_debug (mu_mailbox_t mbox)
— Function: int mu_mailbox_get_debug (mu_mailbox_t mbox, mu_debug_t *debug)

Get a debug object. The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.
ENOMEM

— Function: int mu_mailbox_set_debug (mu_mailbox_t mbox, mu_debug_t debug)
— Function: int mu_mailbox_get_observable (mu_mailbox_t mbox mbox, mu_observable_t *observable)

Get the observable object.

The return value is 0 on success and a code number on error conditions:

MU_ERROR_INVALID_PARAMETER
mbox is NULL.
ENOMEM
Not enough memory.

— Function: int mu_mailbox_lock (mu_mailbox_t mbox)
— Function: int mu_mailbox_unlock (mu_mailbox_t mbox)