## CamelService

CamelService

## Functions

GQuark | camel_service_error_quark ()
void | camel_service_migrate_files ()
CamelURL * | camel_service_new_camel_url ()
CamelServiceConnectionStatus | camel_service_get_connection_status ()
const gchar * | camel_service_get_display_name ()
gchar * | camel_service_dup_display_name ()
void | camel_service_set_display_name ()
const gchar * | camel_service_get_password ()
gchar * | camel_service_dup_password ()
void | camel_service_set_password ()
const gchar * | camel_service_get_user_data_dir ()
const gchar * | camel_service_get_user_cache_dir ()
gchar * | camel_service_get_name ()
CamelProvider * | camel_service_get_provider ()
GProxyResolver * | camel_service_ref_proxy_resolver ()
void | camel_service_set_proxy_resolver ()
struct _CamelSession * | camel_service_ref_session ()
CamelSettings * | camel_service_ref_settings ()
void | camel_service_set_settings ()
const gchar * | camel_service_get_uid ()
void | camel_service_queue_task ()
gboolean | camel_service_connect_sync ()
void | camel_service_connect ()
gboolean | camel_service_connect_finish ()
gboolean | camel_service_disconnect_sync ()
void | camel_service_disconnect ()
gboolean | camel_service_disconnect_finish ()
CamelAuthenticationResult | camel_service_authenticate_sync ()
void | camel_service_authenticate ()
CamelAuthenticationResult | camel_service_authenticate_finish ()
GList * | camel_service_query_auth_types_sync ()
void | camel_service_query_auth_types ()
GList * | camel_service_query_auth_types_finish ()
CamelServiceAuthType * | camel_service_auth_type_copy ()
void | camel_service_auth_type_free ()

## Properties

CamelServiceConnectionStatus | connection-status | Read
char * | display-name | Read / Write / Construct
char * | password | Read / Write / Construct
CamelProvider * | provider | Read / Write / Construct Only
GProxyResolver * | proxy-resolver | Read / Write
CamelSession * | session | Read / Write / Construct Only
CamelSettings * | settings | Read / Write / Construct
char * | uid | Read / Write / Construct Only

## Types and Values

#define | CAMEL_SERVICE_ERROR
enum | CamelServiceError

## Object Hierarchy

        GBoxed
        ╰── CamelServiceAuthType
        GObject
        ╰── CamelObject
            ╰── CamelService
                ├── CamelStore
                ╰── CamelTransport

## Description

## Functions

### camel_service_error_quark ()

    GQuark
    camel_service_error_quark (void);

### camel_service_migrate_files ()

    void
    camel_service_migrate_files (CamelService *service);

Performs any necessary file migrations for `service` . This should be called after installing or configuring the `service` 's CamelSettings, since it requires building a URL string for `service` .

#### Parameters

service | a CamelService |

Since: 3.4

### camel_service_new_camel_url ()

    CamelURL *
    camel_service_new_camel_url (CamelService *service);

Returns a new CamelURL representing `service` . Free the returned CamelURL with `camel_url_free()`.

#### Parameters

service | a CamelService |

#### Returns

a new CamelURL

Since: 3.2

### camel_service_get_connection_status ()

    CamelServiceConnectionStatus
    camel_service_get_connection_status (CamelService *service);

Returns the connection status for `service` .

#### Parameters

service | a CamelService |

#### Returns

the connection status

Since: 3.2

### camel_service_get_display_name ()

    const gchar *
    camel_service_get_display_name (CamelService *service);

Returns the display name for `service` , or `NULL` if `service` has not been given a display name. The display name is intended for use in a user interface and should generally be given a user-defined name.

Compare this with `camel_service_get_name()`, which returns a built-in description of the type of service (IMAP, SMTP, etc.).

#### Parameters

service | a CamelService |

#### Returns

the display name for `service` , or `NULL`.

[nullable]

Since: 3.2

### camel_service_dup_display_name ()

    gchar *
    camel_service_dup_display_name (CamelService *service);

Thread-safe variation of `camel_service_get_display_name()`. Use this function when accessing `service` from multiple threads.

The returned string should be freed with `g_free()` when no longer needed.

#### Parameters

service | a CamelService |

#### Returns

a newly-allocated copy of “display-name”.

[nullable]

Since: 3.12

### camel_service_set_display_name ()

    void
    camel_service_set_display_name (CamelService *service,
                                    const gchar *display_name);

Assigns a UTF-8 display name to `service` . The display name is intended for use in a user interface and should generally be given a user-defined name.

Compare this with `camel_service_get_name()`, which returns a built-in description of the type of service (IMAP, SMTP, etc.).

#### Parameters

service | a CamelService |
display_name | a valid UTF-8 string, or `NULL`. | [nullable]

Since: 3.2

### camel_service_get_password ()

    const gchar *
    camel_service_get_password (CamelService *service);

Returns the password for `service` . Some SASL mechanisms use this when attempting to authenticate.

#### Parameters

service | a CamelService |

#### Returns

the password for `service`

Since: 3.4

### camel_service_dup_password ()

    gchar *
    camel_service_dup_password (CamelService *service);

Thread-safe variation of `camel_service_get_password()`. Use this function when accessing `service` from multiple threads.

The returned string should be freed with `g_free()` when no longer needed.

#### Parameters

service | a CamelService |

#### Returns

a newly-allocated copy of “password”

Since: 3.12

### camel_service_set_password ()

    void
    camel_service_set_password (CamelService *service,
                                const gchar *password);

Sets the password for `service` . Use this function to cache the password in memory after obtaining it through `camel_session_get_password()`. Some SASL mechanisms use this when attempting to authenticate.

#### Parameters

service | a CamelService |
password | the password for `service` |

Since: 3.4

### camel_service_get_user_data_dir ()

    const gchar *
    camel_service_get_user_data_dir (CamelService *service);

Returns the base directory under which to store user-specific data for `service` . The directory is formed by appending the directory returned by `camel_session_get_user_data_dir()` with the service's “uid” value.

#### Parameters

service | a CamelService |

#### Returns

the base directory for `service`

Since: 3.2

### camel_service_get_user_cache_dir ()

    const gchar *
    camel_service_get_user_cache_dir (CamelService *service);

Returns the base directory under which to store cache data for `service` . The directory is formed by appending the directory returned by `camel_session_get_user_cache_dir()` with the service's “uid” value.

#### Parameters

service | a CamelService |

#### Returns

the base cache directory for `service`

Since: 3.4

### camel_service_get_name ()

    gchar *
    camel_service_get_name (CamelService *service,
                            gboolean brief);

This gets the name of the service in a "friendly" (suitable for humans) form. If `brief` is `TRUE`, this should be a brief description such as for use in the folder tree. If `brief` is `FALSE`, it should be a more complete and mostly unambiguous description.

#### Parameters

service | a CamelService |
brief | whether or not to use a briefer form |

#### Returns

a description of the service which the caller must free

### camel_service_get_provider ()

    CamelProvider *
    camel_service_get_provider (CamelService *service);

Gets the CamelProvider associated with the service.

#### Parameters

service | a CamelService |

#### Returns

the CamelProvider

### camel_service_ref_proxy_resolver ()

    GProxyResolver *
    camel_service_ref_proxy_resolver (CamelService *service);

Returns the GProxyResolver for `service` . If an application needs to override this, it should do so prior to calling functions on `service` that may require a network connection.

The returned GProxyResolver is referenced for thread-safety and must be unreferenced with `g_object_unref()` when finished with it.

#### Parameters

service | a CamelService |

#### Returns

a GProxyResolver, or `NULL`.

[transfer full][nullable]

Since: 3.12

### camel_service_set_proxy_resolver ()

    void
    camel_service_set_proxy_resolver (CamelService *service,
                                      GProxyResolver *proxy_resolver);

Sets the GProxyResolver for `service` . If an application needs to override this, it should do so prior to calling functions on `service` that may require a network connection.

#### Parameters

service | a CamelService |
proxy_resolver | a GProxyResolver, or `NULL` for the default. | [nullable]

Since: 3.12

### camel_service_ref_session ()

    struct _CamelSession *
    camel_service_ref_session (CamelService *service);

Returns the CamelSession associated with the service.

The returned CamelSession is referenced for thread-safety. Unreference the CamelSession with `g_object_unref()` when finished with it.

#### Parameters

service | a CamelService |

#### Returns

the CamelSession.

[transfer full][type CamelSession]

Since: 3.8

### camel_service_ref_settings ()

    CamelSettings *
    camel_service_ref_settings (CamelService *service);

Returns the CamelSettings instance associated with the service.

The returned CamelSettings is referenced for thread-safety and must be unreferenced with `g_object_unref()` when finished with it.

#### Parameters

service | a CamelService |

#### Returns

the CamelSettings.

[transfer full]

Since: 3.6

### camel_service_set_settings ()

    void
    camel_service_set_settings (CamelService *service,
                                CamelSettings *settings);

Associates a new CamelSettings instance with the service. The `settings` instance must match the settings type defined in CamelServiceClass. If `settings` is `NULL`, a new CamelSettings instance of the appropriate type is created with all properties set to defaults.

#### Parameters

service | a CamelService |
settings | an instance derviced from CamelSettings, or `NULL`. | [nullable]

Since: 3.2

### camel_service_get_uid ()

    const gchar *
    camel_service_get_uid (CamelService *service);

Gets the unique identifier string associated with the service.

#### Parameters

service | a CamelService |

#### Returns

the UID string

Since: 3.2

### camel_service_queue_task ()

    void
    camel_service_queue_task (CamelService *service,
                              GTask *task,
                              GTaskThreadFunc task_func);

Adds `task` to a queue of waiting tasks with the same source object. Queued tasks execute one at a time in the order they were added. When `task` reaches the front of the queue, it will be dispatched by invoking `task_func` in a separate thread. If `task` is cancelled while queued, it will complete immediately with an appropriate error.

This is primarily intended for use by CamelStore, CamelTransport and CamelFolder to achieve ordered invocation of synchronous class methods.

#### Parameters

service | a CamelService |
task | a GTask |
task_func | function to call when `task` is dispatched. | [scope async]

Since: 3.12

### camel_service_connect_sync ()

    gboolean
    camel_service_connect_sync (CamelService *service,
                                GCancellable *cancellable,
                                GError **error);

Connects `service` to a remote server using the information in its “settings” instance.

If a connect operation is already in progress when this function is called, its results will be reflected in this connect operation.

#### Parameters

service | a CamelService |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` if the connection is made or `FALSE` otherwise

Since: 3.6

### camel_service_connect ()

    void
    camel_service_connect (CamelService *service,
                           gint io_priority,
                           GCancellable *cancellable,
                           GAsyncReadyCallback callback,
                           gpointer user_data);

Asynchronously connects `service` to a remote server using the information in its “settings” instance.

If a connect operation is already in progress when this function is called, its results will be reflected in this connect operation.

If any disconnect operations are in progress when this function is called, they will be cancelled.

When the operation is finished, `callback` will be called. You can then call `camel_service_connect_finish()` to get the result of the operation.

#### Parameters

service | a CamelService |
io_priority | the I/O priority of the request |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since: 3.6

### camel_service_connect_finish ()

    gboolean
    camel_service_connect_finish (CamelService *service,
                                  GAsyncResult *result,
                                  GError **error);

Finishes the operation started with `camel_service_connect()`.

#### Parameters

service | a CamelService |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` if the connection was made or `FALSE` otherwise

Since: 3.6

### camel_service_disconnect_sync ()

    gboolean
    camel_service_disconnect_sync (CamelService *service,
                                   gboolean clean,
                                   GCancellable *cancellable,
                                   GError **error);

Disconnect from the service. If `clean` is `FALSE`, it should not try to do any synchronizing or other cleanup of the connection.

If a disconnect operation is already in progress when this function is called, its results will be reflected in this disconnect operation.

If any connect operations are in progress when this function is called, they will be cancelled.

#### Parameters

service | a CamelService |
clean | whether or not to try to disconnect cleanly |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` if the connection was severed or `FALSE` otherwise

Since: 3.6

### camel_service_disconnect ()

    void
    camel_service_disconnect (CamelService *service,
                              gboolean clean,
                              gint io_priority,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

If a disconnect operation is already in progress when this function is called, its results will be reflected in this disconnect operation.

If any connect operations are in progress when this function is called, they will be cancelled.

When the operation is finished, `callback` will be called. You can then call `camel_service_disconnect_finish()` to get the result of the operation.

#### Parameters

service | a CamelService |
clean | whether or not to try to disconnect cleanly |
io_priority | the I/O priority of the request |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since: 3.6

### camel_service_disconnect_finish ()

    gboolean
    camel_service_disconnect_finish (CamelService *service,
                                     GAsyncResult *result,
                                     GError **error);

Finishes the operation started with `camel_service_disconnect()`.

#### Parameters

service | a CamelService |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` if the connection was severed or `FALSE` otherwise

Since: 3.6

### camel_service_authenticate_sync ()

    CamelAuthenticationResult
    camel_service_authenticate_sync (CamelService *service,
                                     const gchar *mechanism,
                                     GCancellable *cancellable,
                                     GError **error);

Attempts to authenticate `service` using `mechanism` and, if necessary, `service` 's “password” property. The function makes only ONE attempt at authentication and does not loop.

If the authentication attempt completed and the server accepted the credentials, the function returns CAMEL_AUTHENTICATION_ACCEPTED.

If the authentication attempt completed but the server rejected the credentials, the function returns CAMEL_AUTHENTICATION_REJECTED.

If the authentication attempt failed to complete due to a network communication issue or some other mishap, the function sets `error` and returns CAMEL_AUTHENTICATION_ERROR.

Generally this function should only be called from a CamelSession subclass in order to implement its own authentication loop.

#### Parameters

service | a CamelService |
mechanism | a SASL mechanism name, or `NULL`. | [nullable]
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

the authentication result

Since: 3.4

### camel_service_authenticate ()

    void
    camel_service_authenticate (CamelService *service,
                                const gchar *mechanism,
                                gint io_priority,
                                GCancellable *cancellable,
                                GAsyncReadyCallback callback,
                                gpointer user_data);

Asynchronously attempts to authenticate `service` using `mechanism` and, if necessary, `service` 's “password” property. The function makes only ONE attempt at authentication and does not loop.

Generally this function should only be called from a CamelSession subclass in order to implement its own authentication loop.

When the operation is finished, `callback` will be called. You can then call `camel_service_authenticate_finish()` to get the result of the operation.

#### Parameters

service | a CamelService |
mechanism | a SASL mechanism name, or `NULL`. | [nullable]
io_priority | the I/O priority of the request |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since: 3.4

### camel_service_authenticate_finish ()

    CamelAuthenticationResult
    camel_service_authenticate_finish (CamelService *service,
                                       GAsyncResult *result,
                                       GError **error);

Finishes the operation started with `camel_service_authenticate()`.

If the authentication attempt completed and the server accepted the credentials, the function returns CAMEL_AUTHENTICATION_ACCEPTED.

If the authentication attempt completed but the server rejected the credentials, the function returns CAMEL_AUTHENTICATION_REJECTED.

If the authentication attempt failed to complete due to a network communication issue or some other mishap, the function sets `error` and returns CAMEL_AUTHENTICATION_ERROR.

#### Parameters

service | a CamelService |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

the authentication result

Since: 3.4

### camel_service_query_auth_types_sync ()

    GList *
    camel_service_query_auth_types_sync (CamelService *service,
                                         GCancellable *cancellable,
                                         GError **error);

Obtains a list of authentication types supported by `service` . Free the returned list with `g_list_free()`.

#### Parameters

service | a CamelService |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

a list of CamelServiceAuthType structs.

[element-type CamelServiceAuthType][transfer container]

### camel_service_query_auth_types ()

    void
    camel_service_query_auth_types (CamelService *service,
                                    gint io_priority,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously obtains a list of authentication types supported by `service` .

When the operation is finished, `callback` will be called. You can then call `camel_service_query_auth_types_finish()` to get the result of the operation.

#### Parameters

service | a CamelService |
io_priority | the I/O priority of the request |
cancellable | optional GCancellable object, or `NULL` |
callback | a GAsyncReadyCallback to call when the request is satisfied |
user_data | data to pass to the callback function |

Since: 3.2

### camel_service_query_auth_types_finish ()

    GList *
    camel_service_query_auth_types_finish (CamelService *service,
                                           GAsyncResult *result,
                                           GError **error);

Finishes the operation started with `camel_service_query_auth_types()`. Free the returned list with `g_list_free()`.

#### Parameters

service | a CamelService |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

a list of CamelServiceAuthType structs.

[element-type CamelServiceAuthType][transfer container]

Since: 3.2

### camel_service_auth_type_copy ()

    CamelServiceAuthType *
    camel_service_auth_type_copy (const CamelServiceAuthType *service_auth_type);

Copies the `service_auth_type` struct. Does nothing and returns the given object in reality, needed for the introspection.

#### Parameters

service_auth_type | a CamelServiceAuthType |

#### Returns

the copy of `service_auth_type` .

[transfer full]

Since: 3.24

### camel_service_auth_type_free ()

    void
    camel_service_auth_type_free (CamelServiceAuthType *service_auth_type);

Frees the `service_auth_type` struct. Does nothing in reality, needed for the introspection.

#### Parameters

service_auth_type | a CamelServiceAuthType |

Since: 3.24

## Types and Values

### CAMEL_SERVICE_ERROR

    #define             CAMEL_SERVICE_ERROR

Since: 2.32

### enum CamelServiceError

#### Members

CAMEL_SERVICE_ERROR_INVALID | a generic service error code |
CAMEL_SERVICE_ERROR_URL_INVALID | the URL for the service is invalid |
CAMEL_SERVICE_ERROR_UNAVAILABLE | the service is unavailable |
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE | failed to authenitcate |
CAMEL_SERVICE_ERROR_NOT_CONNECTED | the service is not connected |

Since: 2.32

## Property Details

### The `“connection-status”` property

      “connection-status”        CamelServiceConnectionStatus

The connection status for the service.

Owner: CamelService

Flags: Read

Default value: CAMEL_SERVICE_DISCONNECTED

### The `“display-name”` property

      “display-name”             char *

The display name for the service.

Owner: CamelService

Flags: Read / Write / Construct

Default value: NULL

### The `“password”` property

      “password”                 char *

The password for the service.

Owner: CamelService

Flags: Read / Write / Construct

Default value: NULL

### The `“provider”` property

      “provider”                 CamelProvider *

The CamelProvider for the service.

Owner: CamelService

Flags: Read / Write / Construct Only

### The `“proxy-resolver”` property

      “proxy-resolver”           GProxyResolver *

The proxy resolver for the service.

Owner: CamelService

Flags: Read / Write

### The `“session”` property

      “session”                  CamelSession *

A CamelSession instance.

Owner: CamelService

Flags: Read / Write / Construct Only

### The `“settings”` property

      “settings”                 CamelSettings *

A CamelSettings instance.

Owner: CamelService

Flags: Read / Write / Construct

### The `“uid”` property

      “uid”                      char *

The unique identity of the service.

Owner: CamelService

Flags: Read / Write / Construct Only

Default value: NULL