mail-storage.h revision 58b8f5023718a1afcdae25dc418b5a31c4502d64
#ifndef __MAIL_STORAGE_H
#define __MAIL_STORAGE_H
#include "imap-util.h"
#include "imap-parser.h"
typedef enum {
MAILBOX_NOSELECT = 0x01,
MAILBOX_CHILDREN = 0x02,
MAILBOX_NOCHILDREN = 0x04,
MAILBOX_NOINFERIORS = 0x08,
MAILBOX_MARKED = 0x10,
MAILBOX_UNMARKED = 0x20,
MAILBOX_READONLY = 0x40
} MailboxFlags;
typedef enum {
STATUS_MESSAGES = 0x01,
STATUS_RECENT = 0x02,
STATUS_UIDNEXT = 0x04,
STATUS_UIDVALIDITY = 0x08,
STATUS_UNSEEN = 0x10,
STATUS_FIRST_UNSEEN_SEQ = 0x20,
STATUS_CUSTOM_FLAGS = 0x40
typedef enum {
typedef enum {
} ModifyType;
typedef struct _MailStorage MailStorage;
typedef struct _MailboxStatus MailboxStatus;
typedef struct _MailFetchData MailFetchData;
typedef struct _MailFetchBodyData MailFetchBodyData;
typedef struct _MailSearchArg MailSearchArg;
const char *custom_flags[],
void *context);
/* All methods returning int return either TRUE or FALSE. */
struct _MailStorage {
char *name;
char hierarchy_sep;
/* Create new instance */
/* Free this instance */
/* Returns TRUE if this storage would accept the given data
as a valid parameter to create(). */
int (*autodetect)(const char *data);
/* Open a mailbox. If readonly is TRUE, mailbox must not be
modified in any way even when it's asked. */
int readonly);
/* name is allowed to contain multiple new hierarchy levels */
/* If the name has inferior hierarchical names, then the inferior
hierarchical names MUST also be renamed (ie. foo -> bar renames
If oldname is case-insensitively "INBOX", the mails are moved
into new folder but the INBOX folder must not be deleted. */
const char *newname);
/* Execute specified function for all mailboxes matching given
mask. The mask is in RFC2060 LIST format. */
/* Subscribe/unsubscribe mailbox. There should be no error when
subscribing to already subscribed mailbox. Subscribing to
unexisting mailboxes is optional. */
/* Exactly like find_mailboxes(), but list only subscribed mailboxes. */
/* Returns mailbox name status */
/* Returns the error message of last occured error. */
/* private: */
char *dir; /* root directory */
char *user; /* name of user accessing the storage */
char *error;
};
struct _Mailbox {
char *name;
/* Close the box */
/* Gets the mailbox status information. */
/* Synchronize the mailbox by reading all expunges and flag changes.
If new mail has been added to mailbox, messages contains the total
number of messages in mailbox, otherwise 0. functions may be NULL.
If expunge is TRUE, deleted mails are expunged as well. Difference
to expunge() function is that expunge_func is also called. */
void *context);
/* Expunge all mails with \Deleted flag. */
/* Update mail flags. func may be NULL. */
int *all_found);
/* Copy mails to another mailbox */
const char *messageset, int uidset);
/* Fetch wanted mail data. The results are written into outbuf
in RFC2060 FETCH format. */
/* Search wanted mail data. args contains the search criteria.
results are written into outbuf in RFC2060 SEARCH format. */
/* Save a new mail into mailbox. */
/* Returns TRUE if mailbox is now in inconsistent state, meaning that
the message IDs etc. may have changed - only way to recover this
would be to fully close the mailbox and reopen it. With IMAP
connection this would mean a forced disconnection since we can't
do forced CLOSE. */
/* private: */
unsigned int readonly:1;
unsigned int inconsistent:1;
};
struct _MailboxStatus {
unsigned int messages;
unsigned int recent;
unsigned int unseen;
unsigned int uidvalidity;
unsigned int uidnext;
unsigned int first_unseen_seq;
/* may be allocated from temp pool */
const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT];
};
struct _MailFetchData {
const char *messageset;
unsigned int uidset:1;
unsigned int body:1;
unsigned int bodystructure:1;
unsigned int envelope:1;
unsigned int flags:1;
unsigned int internaldate:1;
unsigned int rfc822:1;
unsigned int rfc822_header:1;
unsigned int rfc822_size:1;
unsigned int rfc822_text:1;
unsigned int uid:1;
};
struct _MailFetchBodyData {
const char *section; /* NOTE: always uppercased */
set it to (uoff_t)-1 */
unsigned int skip_set:1;
unsigned int peek:1;
};
/* register all mail storages */
void mail_storage_register_all(void);
/* Register mail storage class with given name - all methods that are NULL
are set to default methods */
/* Create a new instance of registered mail storage class with given
storage-specific data. If data is NULL, it tries to use defaults.
May return NULL if anything fails. */
const char *user);
/* Set error message in storage. Critical errors are logged with i_error(),
but user sees only "internal error" message. */
#endif