CamelIMAPPEngine
3
CAMEL Library

# CamelIMAPPEngine

## Synopsis

                        CamelIMAPPEngine;
                        CamelIMAPPCommandPart;
                        CamelIMAPPCommand;
    enum                camel_imapp_command_part_t;
    int                 (*CamelIMAPPEngineFunc)             (struct _CamelIMAPPEngine *engine,
                                                             guint32 id,
                                                             void *data);
    void                (*CamelIMAPPCommandFunc)            (struct _CamelIMAPPEngine *engine,
                                                             struct _CamelIMAPPCommand *,
                                                             void *data);
                        CamelIMAPPSelectResponse;
    enum                camel_imapp_engine_state_t;
    CamelIMAPPEngine*   camel_imapp_engine_new              (CamelIMAPPStream *stream);
    void                camel_imapp_engine_add_handler      (CamelIMAPPEngine *imap,
                                                             const char *response,
                                                             CamelIMAPPEngineFunc func,
                                                             void *data);
    int                 camel_imapp_engine_iterate          (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *wait);
    int                 camel_imapp_engine_skip             (CamelIMAPPEngine *imap);
    int                 camel_imapp_engine_capabilities     (CamelIMAPPEngine *imap);
    CamelIMAPPCommand*  camel_imapp_engine_command_new      (CamelIMAPPEngine *imap,
                                                             const char *name,
                                                             const char *select,
                                                             const char *fmt,
                                                             ...);
    void                camel_imapp_engine_command_complete (CamelIMAPPEngine *imap,
                                                             struct _CamelIMAPPCommand *,
                                                             CamelIMAPPCommandFunc func,
                                                             void *data);
    void                camel_imapp_engine_command_add      (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic,
                                                             const char *fmt,
                                                             ...);
    void                camel_imapp_engine_command_free     (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic);
    void                camel_imapp_engine_command_queue    (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic);
    CamelIMAPPCommand*  camel_imapp_engine_command_find     (CamelIMAPPEngine *imap,
                                                             const char *name);
    CamelIMAPPCommand*  camel_imapp_engine_command_find_tag (CamelIMAPPEngine *imap,
                                                             unsigned int tag);
    CamelIMAPPSelectResponse* camel_imapp_engine_select     (CamelIMAPPEngine *imap,
                                                             const char *name);
    void                camel_imapp_engine_select_free      (CamelIMAPPEngine *imap,
                                                             CamelIMAPPSelectResponse *select);

## Description

## Details

### CamelIMAPPEngine

    typedef struct {
    	CamelObject parent_object;

    	/* incoming requests */
    	EMsgPort *port;

    	CamelIMAPPStream *stream;

    	camel_imapp_engine_state_t state;

    	guint32 capa;		/* capabilities for this server, refresh with :capabilities() */

    	GHashTable *handlers;

    	unsigned char tagprefix; /* out tag prefix 'A' 'B' ... 'Z' */
    	unsigned int tag;	/* next command tag */

    	char *select;		/* *currently* selected folder */
    	char *last_select;	/* last selected or to-be selected folder (e.g. outstanding queued select) */
    	CamelIMAPPCommand *literal;/* current literal op */
    	EDList active;		/* active queue */
    	EDList queue;		/* outstanding queue */
    	EDList done;		/* done queue, awaiting reclamation */

    	/* keep track of running a select */
    	struct _CamelIMAPPSelectResponse *select_response;
    } CamelIMAPPEngine;

### CamelIMAPPCommandPart

    typedef struct {
    	struct _CamelIMAPPCommandPart *next;
    	struct _CamelIMAPPCommandPart *prev;

    	struct _CamelIMAPPCommand *parent;

    	int data_size;
    	char *data;

    	camel_imapp_command_part_t type;

    	int ob_size;
    	CamelObject *ob;
    } CamelIMAPPCommandPart;

### CamelIMAPPCommand

    typedef struct {
    	EMsg msg;

    	const char *name;	/* command name/type (e.g. FETCH) */

    	/* FIXME: remove this select stuff */
    	char *select;		/* if we need to run against a specific folder */
    	struct _status_info *status; /* status for command, indicates it is complete if != NULL */

    	unsigned int tag;

    	struct _CamelStreamMem *mem;	/* for building the part */
    	EDList parts;
    	CamelIMAPPCommandPart *current;

    	CamelIMAPPCommandFunc complete;
    	void *complete_data;
    } CamelIMAPPCommand;

### enum camel_imapp_command_part_t

    typedef enum {
    	CAMEL_IMAPP_COMMAND_SIMPLE = 0,
    	CAMEL_IMAPP_COMMAND_DATAWRAPPER,
    	CAMEL_IMAPP_COMMAND_STREAM,
    	CAMEL_IMAPP_COMMAND_AUTH,
    	CAMEL_IMAPP_COMMAND_MASK = 0xff,
    	CAMEL_IMAPP_COMMAND_CONTINUATION = 0x8000 /* does this command expect continuation? */
    } camel_imapp_command_part_t;

### CamelIMAPPEngineFunc ()

    int                 (*CamelIMAPPEngineFunc)             (struct _CamelIMAPPEngine *engine,
                                                             guint32 id,
                                                             void *data);

`engine` :

`id` :

`data` :

Returns :

### CamelIMAPPCommandFunc ()

    void                (*CamelIMAPPCommandFunc)            (struct _CamelIMAPPEngine *engine,
                                                             struct _CamelIMAPPCommand *,
                                                             void *data);

`engine` :

`Param2` :

`data` :

### CamelIMAPPSelectResponse

    typedef struct {
    	struct _status_info *status;
    	guint32 exists;
    	guint32 recent;
    	guint32 uidvalidity;
    	guint32 unseen;
    	guint32 permanentflags;
    } CamelIMAPPSelectResponse;

### enum camel_imapp_engine_state_t

    typedef enum _camel_imapp_engine_state_t {
    	IMAP_ENGINE_DISCONNECT,	/* only happens during shutdown */
    	IMAP_ENGINE_CONNECT,	/* connected, not authenticated */
    	IMAP_ENGINE_AUTH,	/* connected, and authenticated */
    	IMAP_ENGINE_SELECT,	/* and selected, select holds selected folder */
    } camel_imapp_engine_state_t;

### camel_imapp_engine_new ()

    CamelIMAPPEngine*   camel_imapp_engine_new              (CamelIMAPPStream *stream);

`stream` :

Returns :

### camel_imapp_engine_add_handler ()

    void                camel_imapp_engine_add_handler      (CamelIMAPPEngine *imap,
                                                             const char *response,
                                                             CamelIMAPPEngineFunc func,
                                                             void *data);

`imap` :

`response` :

`func` :

`data` :

### camel_imapp_engine_iterate ()

    int                 camel_imapp_engine_iterate          (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *wait);

`imap` :

`wait` :

Returns :

### camel_imapp_engine_skip ()

    int                 camel_imapp_engine_skip             (CamelIMAPPEngine *imap);

`imap` :

Returns :

### camel_imapp_engine_capabilities ()

    int                 camel_imapp_engine_capabilities     (CamelIMAPPEngine *imap);

`imap` :

Returns :

### camel_imapp_engine_command_new ()

    CamelIMAPPCommand*  camel_imapp_engine_command_new      (CamelIMAPPEngine *imap,
                                                             const char *name,
                                                             const char *select,
                                                             const char *fmt,
                                                             ...);

`imap` :

`name` :

`select` :

`fmt` :

`...` :

Returns :

### camel_imapp_engine_command_complete ()

    void                camel_imapp_engine_command_complete (CamelIMAPPEngine *imap,
                                                             struct _CamelIMAPPCommand *,
                                                             CamelIMAPPCommandFunc func,
                                                             void *data);

`imap` :

`Param2` :

`func` :

`data` :

### camel_imapp_engine_command_add ()

    void                camel_imapp_engine_command_add      (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic,
                                                             const char *fmt,
                                                             ...);

`imap` :

`ic` :

`fmt` :

`...` :

### camel_imapp_engine_command_free ()

    void                camel_imapp_engine_command_free     (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic);

`imap` :

`ic` :

### camel_imapp_engine_command_queue ()

    void                camel_imapp_engine_command_queue    (CamelIMAPPEngine *imap,
                                                             CamelIMAPPCommand *ic);

`imap` :

`ic` :

### camel_imapp_engine_command_find ()

    CamelIMAPPCommand*  camel_imapp_engine_command_find     (CamelIMAPPEngine *imap,
                                                             const char *name);

`imap` :

`name` :

Returns :

### camel_imapp_engine_command_find_tag ()

    CamelIMAPPCommand*  camel_imapp_engine_command_find_tag (CamelIMAPPEngine *imap,
                                                             unsigned int tag);

`imap` :

`tag` :

Returns :

### camel_imapp_engine_select ()

    CamelIMAPPSelectResponse* camel_imapp_engine_select     (CamelIMAPPEngine *imap,
                                                             const char *name);

`imap` :

`name` :

Returns :

### camel_imapp_engine_select_free ()

    void                camel_imapp_engine_select_free      (CamelIMAPPEngine *imap,
                                                             CamelIMAPPSelectResponse *select);

`imap` :

`select` :