## camel-provider camel-provider |

## Synopsis

                        CamelProvider;
    enum                CamelProviderType;
    #define             CAMEL_PROVIDER_IS_LOCAL
    #define             CAMEL_PROVIDER_IS_EXTERNAL
    #define             CAMEL_PROVIDER_IS_SOURCE
    #define             CAMEL_PROVIDER_IS_STORAGE
    #define             CAMEL_PROVIDER_SUPPORTS_SSL
    #define             CAMEL_PROVIDER_HAS_LICENSE
    #define             CAMEL_PROVIDER_DISABLE_SENT_FOLDER
    #define             CAMEL_URL_PART_USER
    #define             CAMEL_URL_PART_AUTH
    #define             CAMEL_URL_PART_PASSWORD
    #define             CAMEL_URL_PART_HOST
    #define             CAMEL_URL_PART_PORT
    #define             CAMEL_URL_PART_PATH
    #define             CAMEL_URL_PART_PATH_DIR
    #define             CAMEL_URL_PART_NEED
    #define             CAMEL_URL_PART_HIDDEN
    #define             CAMEL_PROVIDER_ALLOWS               (prov, flags)
    #define             CAMEL_PROVIDER_NEEDS                (prov, flags)
    #define             CAMEL_PROVIDER_HIDDEN               (prov, flags)
    #define             CAMEL_URL_ALLOW_USER
    #define             CAMEL_URL_ALLOW_AUTH
    #define             CAMEL_URL_ALLOW_PASSWORD
    #define             CAMEL_URL_ALLOW_HOST
    #define             CAMEL_URL_ALLOW_PORT
    #define             CAMEL_URL_ALLOW_PATH
    #define             CAMEL_URL_NEED_USER
    #define             CAMEL_URL_NEED_AUTH
    #define             CAMEL_URL_NEED_PASSWORD
    #define             CAMEL_URL_NEED_HOST
    #define             CAMEL_URL_NEED_PORT
    #define             CAMEL_URL_NEED_PATH
    #define             CAMEL_URL_NEED_PATH_DIR
    #define             CAMEL_URL_HIDDEN_USER
    #define             CAMEL_URL_HIDDEN_AUTH
    #define             CAMEL_URL_HIDDEN_PASSWORD
    #define             CAMEL_URL_HIDDEN_HOST
    #define             CAMEL_URL_HIDDEN_PORT
    #define             CAMEL_URL_HIDDEN_PATH
    #define             CAMEL_URL_FRAGMENT_IS_PATH
    #define             CAMEL_URL_PATH_IS_ABSOLUTE
    #define             CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT(prov)
    enum                CamelProviderConfType;
                        CamelProviderConfEntry;
    #define             CAMEL_PROVIDER_CONF_DEFAULT_USERNAME
    #define             CAMEL_PROVIDER_CONF_DEFAULT_HOSTNAME
    #define             CAMEL_PROVIDER_CONF_DEFAULT_PATH
    int                 (*CamelProviderAutoDetectFunc)      (CamelURL *url,
                                                             GHashTable **auto_detected,
                                                             CamelException *ex);
                        CamelProviderModule;
    void                camel_provider_init                 (void);
    void                camel_provider_load                 (const char *path,
                                                             CamelException *ex);
    void                camel_provider_register             (CamelProvider *provider);
    GList *             camel_provider_list                 (gboolean load);
    CamelProvider *     camel_provider_get                  (const char *url_string,
                                                             CamelException *ex);
    void                camel_provider_module_init          (void);
    int                 camel_provider_auto_detect          (CamelProvider *provider,
                                                             CamelURL *url,
                                                             GHashTable **auto_detected,
                                                             CamelException *ex);

## Description

## Details

### CamelProvider

    typedef struct {
    	/* Provider name used in CamelURLs. */
    	char *protocol;

    	/* Provider name as used by people. (May be the same as protocol) */
    	char *name;

    	/* Description of the provider. A novice user should be able
    	 * to read this description, and the information provided by
    	 * an ISP, IS department, etc, and determine whether or not
    	 * this provider is relevant to him, and if so, which
    	 * information goes with it.
    	 */
    	char *description;

    	/* The category of message that this provider works with.
    	 * (evolution-mail will only list a provider in the store/transport
    	 * config dialogs if its domain is "mail".)
    	 */
    	char *domain;

    	/* Flags describing the provider, flags describing its URLs */
    	int flags, url_flags;

    	/* The ConfEntry and AutoDetect functions will probably be
    	 * DEPRECATED in a future release */

    	/* Extra configuration information */
    	CamelProviderConfEntry *extra_conf;

    	/* auto-detection function */
    	CamelProviderAutoDetectFunc auto_detect;

    	/* CamelType(s) of its store and/or transport. If both are
    	 * set, then they are assumed to be linked together and the
    	 * transport type can only be used in an account that also
    	 * uses the store type (eg, Exchange or NNTP).
    	 */
    	CamelType object_types[CAMEL_NUM_PROVIDER_TYPES];

    	/* GList of CamelServiceAuthTypes the provider supports */
    	GList *authtypes;

    	CamelObjectBag *service_cache[CAMEL_NUM_PROVIDER_TYPES];

    	GHashFunc url_hash;
    	GCompareFunc url_equal;

    	/* gettext translation domain (NULL for providers in the
    	 * evolution source tree).
    	 */
    	char *translation_domain;

    	/* This string points to the provider's gconf key value
    	 */
    	const char *license;

    	/* This holds the license file name [ ascii text format ] containing
    	 * the license agreement. This should be the absolute file path. This
    	 * is read only when the HAS_LICENSE flag is set
    	 */
    	const char *license_file;

    	/* Private to the provider */
    	void *priv;
    } CamelProvider;

### enum CamelProviderType

    typedef enum {
    	CAMEL_PROVIDER_STORE,
    	CAMEL_PROVIDER_TRANSPORT,
    	CAMEL_NUM_PROVIDER_TYPES
    } CamelProviderType;

### CAMEL_PROVIDER_IS_LOCAL

    #define CAMEL_PROVIDER_IS_LOCAL		(1 << 1)

### CAMEL_PROVIDER_IS_EXTERNAL

    #define CAMEL_PROVIDER_IS_EXTERNAL	(1 << 2)

### CAMEL_PROVIDER_IS_SOURCE

    #define CAMEL_PROVIDER_IS_SOURCE	(1 << 3)

### CAMEL_PROVIDER_IS_STORAGE

    #define CAMEL_PROVIDER_IS_STORAGE	(1 << 4)

### CAMEL_PROVIDER_SUPPORTS_SSL

    #define CAMEL_PROVIDER_SUPPORTS_SSL	(1 << 5)

### CAMEL_PROVIDER_HAS_LICENSE

    #define CAMEL_PROVIDER_HAS_LICENSE      (1 << 6)

### CAMEL_PROVIDER_DISABLE_SENT_FOLDER

    #define CAMEL_PROVIDER_DISABLE_SENT_FOLDER (1 << 7)

### CAMEL_URL_PART_USER

    #define CAMEL_URL_PART_USER	 (1 << 0)

### CAMEL_URL_PART_AUTH

    #define CAMEL_URL_PART_AUTH	 (1 << 1)

### CAMEL_URL_PART_PASSWORD

    #define CAMEL_URL_PART_PASSWORD	 (1 << 2)

### CAMEL_URL_PART_HOST

    #define CAMEL_URL_PART_HOST	 (1 << 3)

### CAMEL_URL_PART_PORT

    #define CAMEL_URL_PART_PORT	 (1 << 4)

### CAMEL_URL_PART_PATH

    #define CAMEL_URL_PART_PATH	 (1 << 5)

### CAMEL_URL_PART_PATH_DIR

    #define CAMEL_URL_PART_PATH_DIR  (1 << 6)

### CAMEL_URL_PART_NEED

    #define CAMEL_URL_PART_NEED	       8

### CAMEL_URL_PART_HIDDEN

    #define CAMEL_URL_PART_HIDDEN	(CAMEL_URL_PART_NEED + 8)

### CAMEL_PROVIDER_ALLOWS()

    #define CAMEL_PROVIDER_ALLOWS(prov, flags) (prov->url_flags & (flags | (flags << CAMEL_URL_PART_NEED) | (flags << CAMEL_URL_PART_HIDDEN)))

`prov` : |
`flags` : |

### CAMEL_PROVIDER_NEEDS()

    #define CAMEL_PROVIDER_NEEDS(prov, flags) (prov->url_flags & (flags << CAMEL_URL_PART_NEED))

`prov` : |
`flags` : |

### CAMEL_PROVIDER_HIDDEN()

    #define CAMEL_PROVIDER_HIDDEN(prov, flags) (prov->url_flags & (flags << CAMEL_URL_PART_HIDDEN))

`prov` : |
`flags` : |

### CAMEL_URL_ALLOW_USER

    #define CAMEL_URL_ALLOW_USER	 (CAMEL_URL_PART_USER)

### CAMEL_URL_ALLOW_AUTH

    #define CAMEL_URL_ALLOW_AUTH	 (CAMEL_URL_PART_AUTH)

### CAMEL_URL_ALLOW_PASSWORD

    #define CAMEL_URL_ALLOW_PASSWORD (CAMEL_URL_PART_PASSWORD)

### CAMEL_URL_ALLOW_HOST

    #define CAMEL_URL_ALLOW_HOST	 (CAMEL_URL_PART_HOST)

### CAMEL_URL_ALLOW_PORT

    #define CAMEL_URL_ALLOW_PORT	 (CAMEL_URL_PART_PORT)

### CAMEL_URL_ALLOW_PATH

    #define CAMEL_URL_ALLOW_PATH	 (CAMEL_URL_PART_PATH)

### CAMEL_URL_NEED_USER

    #define CAMEL_URL_NEED_USER	 (CAMEL_URL_PART_USER << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_AUTH

    #define CAMEL_URL_NEED_AUTH	 (CAMEL_URL_PART_AUTH << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_PASSWORD

    #define CAMEL_URL_NEED_PASSWORD	 (CAMEL_URL_PART_PASSWORD << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_HOST

    #define CAMEL_URL_NEED_HOST	 (CAMEL_URL_PART_HOST << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_PORT

    #define CAMEL_URL_NEED_PORT	 (CAMEL_URL_PART_PORT << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_PATH

    #define CAMEL_URL_NEED_PATH	 (CAMEL_URL_PART_PATH << CAMEL_URL_PART_NEED)

### CAMEL_URL_NEED_PATH_DIR

    #define CAMEL_URL_NEED_PATH_DIR  (CAMEL_URL_PART_PATH_DIR << CAMEL_URL_PART_NEED)

### CAMEL_URL_HIDDEN_USER

    #define CAMEL_URL_HIDDEN_USER	 (CAMEL_URL_PART_USER << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_HIDDEN_AUTH

    #define CAMEL_URL_HIDDEN_AUTH	 (CAMEL_URL_PART_AUTH << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_HIDDEN_PASSWORD

    #define CAMEL_URL_HIDDEN_PASSWORD	 (CAMEL_URL_PART_PASSWORD << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_HIDDEN_HOST

    #define CAMEL_URL_HIDDEN_HOST	 (CAMEL_URL_PART_HOST << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_HIDDEN_PORT

    #define CAMEL_URL_HIDDEN_PORT	 (CAMEL_URL_PART_PORT << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_HIDDEN_PATH

    #define CAMEL_URL_HIDDEN_PATH	 (CAMEL_URL_PART_PATH << CAMEL_URL_PART_HIDDEN)

### CAMEL_URL_FRAGMENT_IS_PATH

    #define CAMEL_URL_FRAGMENT_IS_PATH  (1 << 30) /* url uses fragment for folder name path, not path */

### CAMEL_URL_PATH_IS_ABSOLUTE

    #define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 31)

### CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT()

    #define CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT(prov) (prov->object_types[CAMEL_PROVIDER_STORE] && prov->object_types[CAMEL_PROVIDER_TRANSPORT])

`prov` : |

### enum CamelProviderConfType

    typedef enum {
    	CAMEL_PROVIDER_CONF_END,
    	CAMEL_PROVIDER_CONF_SECTION_START,
    	CAMEL_PROVIDER_CONF_SECTION_END,
    	CAMEL_PROVIDER_CONF_CHECKBOX,
    	CAMEL_PROVIDER_CONF_CHECKSPIN,
    	CAMEL_PROVIDER_CONF_ENTRY,
    	CAMEL_PROVIDER_CONF_LABEL,
    	CAMEL_PROVIDER_CONF_HIDDEN,
    	CAMEL_PROVIDER_CONF_OPTIONS
    } CamelProviderConfType;

### CamelProviderConfEntry

    typedef struct {
    	CamelProviderConfType type;
    	char *name, *depname;
    	char *text, *value;
    } CamelProviderConfEntry;

### CAMEL_PROVIDER_CONF_DEFAULT_USERNAME

    #define CAMEL_PROVIDER_CONF_DEFAULT_USERNAME  { CAMEL_PROVIDER_CONF_LABEL, "username", NULL, N_("User_name:"), NULL }

### CAMEL_PROVIDER_CONF_DEFAULT_HOSTNAME

    #define CAMEL_PROVIDER_CONF_DEFAULT_HOSTNAME  { CAMEL_PROVIDER_CONF_LABEL, "hostname", NULL, N_("_Host:"), NULL }

### CAMEL_PROVIDER_CONF_DEFAULT_PATH

    #define CAMEL_PROVIDER_CONF_DEFAULT_PATH      { CAMEL_PROVIDER_CONF_ENTRY, "path", NULL, N_("_Path:"), "" }

### CamelProviderAutoDetectFunc ()

    int                 (*CamelProviderAutoDetectFunc)      (CamelURL *url,
                                                             GHashTable **auto_detected,
                                                             CamelException *ex);

`url` : |
`auto_detected` : |
`ex` : |
Returns : |

### CamelProviderModule

    typedef struct {
    	char *path;
    	GSList *types;
    	guint loaded:1;
    } CamelProviderModule;

### camel_provider_init ()

    void                camel_provider_init                 (void);

Initialize the Camel provider system by reading in the .urls files in the provider directory and creating a hash table mapping URLs to module names.

A .urls file has the same initial prefix as the shared library it correspond to, and consists of a series of lines containing the URL protocols that that library handles.

TODO: This should be pathed? TODO: This should be plugin-d?

### camel_provider_load ()

    void                camel_provider_load                 (const char *path,
                                                             CamelException *ex);

Loads the provider at `path`, and calls its initialization function, passing `session` as an argument. The provider should then register itself with `session`.

`path` : | the path to a shared library
`ex` : | a CamelException

### camel_provider_register ()

    void                camel_provider_register             (CamelProvider *provider);

Registers a provider.

`provider` : | provider object

### camel_provider_list ()

    GList *             camel_provider_list                 (gboolean load);

`load` : |
Returns : |

### camel_provider_get ()

    CamelProvider *     camel_provider_get                  (const char *url_string,
                                                             CamelException *ex);

This returns the CamelProvider that would be used to handle `url_string`, loading it in from disk if necessary.

`url_string` : | the URL for the service whose provider you want
`ex` : | a CamelException
Returns : | the provider, or `NULL`, in which case `ex` will be set.

### camel_provider_module_init ()

    void                camel_provider_module_init          (void);

### camel_provider_auto_detect ()

    int                 camel_provider_auto_detect          (CamelProvider *provider,
                                                             CamelURL *url,
                                                             GHashTable **auto_detected,
                                                             CamelException *ex);

After filling in the standard Username/Hostname/Port/Path settings (which must be set in `url`), if the provider supports it, you may wish to have the provider auto-detect further settings based on the aformentioned settings.

If the provider does not support auto-detection, `auto_detected` will be set to `NULL`. Otherwise the provider will attempt to auto-detect whatever it can and file them into `auto_detected`. If for some reason it cannot auto-detect anything (not enough information provided in `url`?) then `auto_detected` will be set to `NULL` and an exception may be set to explain why it failed.

`provider` : | camel provider
`url` : | a CamelURL
`auto_detected` : | output hash table of auto-detected values
`ex` : | exception
Returns : | 0 on success or -1 on fail.