ESource: Evolution-Data-Server Reference Manual

## ESource ESource — Hierarchical data sources |

## Functions

ESource * | e_source_new ()
ESource * | e_source_new_with_uid ()
guint | e_source_hash ()
gboolean | e_source_equal ()
void | e_source_changed ()
const gchar * | e_source_get_uid ()
gchar * | e_source_dup_uid ()
const gchar * | e_source_get_parent ()
gchar * | e_source_dup_parent ()
void | e_source_set_parent ()
gboolean | e_source_get_enabled ()
void | e_source_set_enabled ()
gboolean | e_source_get_writable ()
gboolean | e_source_get_removable ()
gboolean | e_source_get_remote_creatable ()
gboolean | e_source_get_remote_deletable ()
gpointer | e_source_get_extension ()
gboolean | e_source_has_extension ()
GDBusObject * | e_source_ref_dbus_object ()
GMainContext * | e_source_ref_main_context ()
const gchar * | e_source_get_display_name ()
gchar * | e_source_dup_display_name ()
void | e_source_set_display_name ()
gchar * | e_source_dup_secret_label ()
gint | e_source_compare_by_display_name ()
gchar * | e_source_to_string ()
gchar * | e_source_parameter_to_key ()
ESourceConnectionStatus | e_source_get_connection_status ()
void | e_source_set_connection_status ()
gboolean | e_source_remove_sync ()
void | e_source_remove ()
gboolean | e_source_remove_finish ()
gboolean | e_source_write_sync ()
void | e_source_write ()
gboolean | e_source_write_finish ()
gboolean | e_source_remote_create_sync ()
void | e_source_remote_create ()
gboolean | e_source_remote_create_finish ()
gboolean | e_source_remote_delete_sync ()
void | e_source_remote_delete ()
gboolean | e_source_remote_delete_finish ()
gboolean | e_source_get_oauth2_access_token_sync ()
void | e_source_get_oauth2_access_token ()
gboolean | e_source_get_oauth2_access_token_finish ()
gboolean | e_source_store_password_sync ()
void | e_source_store_password ()
gboolean | e_source_store_password_finish ()
gboolean | e_source_lookup_password_sync ()
void | e_source_lookup_password ()
gboolean | e_source_lookup_password_finish ()
gboolean | e_source_delete_password_sync ()
void | e_source_delete_password ()
gboolean | e_source_delete_password_finish ()
gboolean | e_source_invoke_credentials_required_sync ()
void | e_source_invoke_credentials_required ()
gboolean | e_source_invoke_credentials_required_finish ()
gboolean | e_source_invoke_authenticate_sync ()
void | e_source_invoke_authenticate ()
gboolean | e_source_invoke_authenticate_finish ()
void | e_source_emit_credentials_required ()
gboolean | e_source_get_last_credentials_required_arguments_sync ()
void | e_source_get_last_credentials_required_arguments ()
gboolean | e_source_get_last_credentials_required_arguments_finish ()
gboolean | e_source_unset_last_credentials_required_arguments_sync ()
void | e_source_unset_last_credentials_required_arguments ()
gboolean | e_source_unset_last_credentials_required_arguments_finish ()

## Types and Values

#define | E_SOURCE_PARAM_SETTING
#define | E_SOURCE_CREDENTIAL_USERNAME
#define | E_SOURCE_CREDENTIAL_PASSWORD
#define | E_SOURCE_CREDENTIAL_SSL_TRUST
struct | ESource

## Object Hierarchy

        GObject
        ╰── ESource
            ╰── EServerSideSource

## Implemented Interfaces

ESource implements GInitable and GProxyResolver.

## Includes

    #include <libedataserver/libedataserver.h>

## Description

An ESource (or "data source") is a description of a file or network location where data can be obtained (such as a mail account), or a description of a resource at that location (such as a mail folder).

In more concrete terms, it's an interface for a key file. All such key files have a main group named [Data Source]. The keys in a [Data Source] group map to GObject properties in an ESource.

Additional groups in the key file are referred to as "extensions". ESourceExtension serves as the base class for writing interfaces for these additional key file groups. The keys in one of these key file groups map to GObject properties in some custom subclass of ESourceExtension which was written specifically for that key file group. For example, a key file might include a group named [Calendar], whose keys map to GObject properties in an extension class named ESourceCalendar.

Each ESource contains an internal dictionary of extension objects, accessible by their key file group name. `e_source_get_extension()` can look up extension objects by name.

An ESource is identified by a unique identifier string, or "UID", which is also the basename of the corresponding key file. Additional files related to the ESource, such as cache files, are usually kept in a directory named after the UID of the ESource. Similarly, the password for an account described by an ESource is kept in GNOME Keyring under the UID of the ESource. This makes finding these additional resources simple.

Several extensions for common information such as authentication details are built into libedataserver (ESourceAuthentication, for example). Backend modules may also define their own extensions for information and settings unique to the backend. ESourceExtension subclasses written for specific backends are generally not available to applications and shared libraries. This is by design, to try and keep backend-specific knowledge from creeping into places it doesn't belong.

As of 3.12, an ESource with an ESourceProxy extension can serve as a GProxyResolver. Calling `g_proxy_resolver_is_supported()` on an ESource will reflect this constraint. Attempting a proxy lookup operation on an ESource for which `g_proxy_resolver_is_supported()` returns `FALSE` will fail with `G_IO_ERROR_NOT_SUPPORTED`.

## Functions

### e_source_new ()

    ESource *
    e_source_new (GDBusObject *dbus_object,
                  GMainContext *main_context,
                  GError **error);

Creates a new ESource instance.

The “changed” signal will be emitted from `main_context` if given, or else from the thread-default GMainContext at the time this function is called.

The only time the function should be called outside of ESourceRegistry is to create a so-called "scratch" ESource for editing in a Properties window or an account setup assistant.

FIXME: Elaborate on scratch sources.

#### Parameters

dbus_object | a GDBusObject or `NULL`. | [nullable]
main_context | a GMainContext or `NULL`. | [nullable]
error | return location for a GError, or `NULL` |

#### Returns

a new ESource, or `NULL` on error

Since: 3.6

### e_source_new_with_uid ()

    ESource *
    e_source_new_with_uid (const gchar *uid,
                           GMainContext *main_context,
                           GError **error);

Creates a new "scratch" ESource with a predetermined unique identifier.

The “changed” signal will be emitted from `main_context` if given, or else from the thread-default GMainContext at the time this function is called.

#### Parameters

uid | a new unique identifier string |
main_context | a GMainContext or `NULL`. | [nullable]
error | return location for a GError, or `NULL` |

#### Returns

a new scratch ESource, or `NULL` on error

Since: 3.6

### e_source_hash ()

    guint
    e_source_hash (ESource *source);

Generates a hash value for `source` . This function is intended for easily hashing an ESource to add to a GHashTable or similar data structure.

#### Parameters

source | an ESource |

#### Returns

a hash value for `source` .

Since: 3.6

### e_source_equal ()

    gboolean
    e_source_equal (ESource *source1,
                    ESource *source2);

Checks two ESource instances for equality. ESource instances are equal if their unique identifier strings are equal.

#### Parameters

source1 | the first ESource |
source2 | the second ESource |

#### Returns

`TRUE` if `source1` and `source2` are equal

Since: 3.6

### e_source_changed ()

    void
    e_source_changed (ESource *source);

Emits the “changed” signal from an idle callback in `source` 's “main-context”.

This function is primarily intended for use by ESourceExtension when emitting a “notify” signal on one of its properties.

#### Parameters

source | an ESource |

Since: 3.6

### e_source_get_uid ()

    const gchar *
    e_source_get_uid (ESource *source);

Returns the unique identifier string for `source` .

#### Parameters

source | an ESource |

#### Returns

the UID for `source`

Since: 3.6

### e_source_dup_uid ()

    gchar *
    e_source_dup_uid (ESource *source);

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

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

#### Parameters

source | an ESource |

#### Returns

a newly-allocated copy of “uid”

Since: 3.6

### e_source_get_parent ()

    const gchar *
    e_source_get_parent (ESource *source);

Returns the unique identifier string of the parent ESource.

#### Parameters

source | an ESource |

#### Returns

the UID of the parent ESource.

[nullable]

Since: 3.6

### e_source_dup_parent ()

    gchar *
    e_source_dup_parent (ESource *source);

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

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

#### Parameters

source | an ESource |

#### Returns

a newly-allocated copy of “parent”.

[nullable]

Since: 3.6

### e_source_set_parent ()

    void
    e_source_set_parent (ESource *source,
                         const gchar *parent);

Identifies the parent of `source` by its unique identifier string. This can only be set prior to adding `source` to an ESourceRegistry.

The internal copy of “parent” is automatically stripped of leading and trailing whitespace. If the resulting string is empty, `NULL` is set instead.

#### Parameters

source | an ESource |
parent | the UID of the parent ESource, or `NULL`. | [nullable]

Since: 3.6

### e_source_get_enabled ()

    gboolean
    e_source_get_enabled (ESource *source);

Returns `TRUE` if `source` is enabled.

An application should try to honor this setting if at all possible, even if it does not provide a way to change the setting through its user interface. Disabled data sources should generally be hidden.

This function does not take into account `source`'s ancestors in the ESource hierarchy, each of which have their own enabled state. If any of `source`'s ancestors are disabled, then `source` itself should be treated as disabled. Use `e_source_registry_check_enabled()` to easily check for this.

#### Parameters

source | an ESource |

#### Returns

whether `source` is enabled

Since: 3.6

### e_source_set_enabled ()

    void
    e_source_set_enabled (ESource *source,
                          gboolean enabled);

Enables or disables `source` .

An application should try to honor this setting if at all possible, even if it does not provide a way to change the setting through its user interface. Disabled data sources should generally be hidden.

#### Parameters

source | an ESource |
enabled | whether to enable `source` |

Since: 3.6

### e_source_get_writable ()

    gboolean
    e_source_get_writable (ESource *source);

Returns whether the D-Bus service will accept changes to `source` . If `source` is not writable, calls to `e_source_write()` will fail.

#### Parameters

source | an ESource |

#### Returns

whether `source` is writable

Since: 3.6

### e_source_get_removable ()

    gboolean
    e_source_get_removable (ESource *source);

Returns whether the D-Bus service will allow `source` to be removed. If `source` is not writable, calls to `e_source_remove()` will fail.

#### Parameters

source | an ESource |

#### Returns

whether `source` is removable

Since: 3.6

### e_source_get_remote_creatable ()

    gboolean
    e_source_get_remote_creatable (ESource *source);

Returns whether new resources can be created on a remote server by calling `e_source_remote_create()` on `source` .

Generally this is only `TRUE` if `source` has an ESourceCollection extension, which means there is an ECollectionBackend in the D-Bus service that can handle create requests. If `source` does not have this capability, calls to `e_source_remote_create()` will fail.

#### Parameters

source | an ESource |

#### Returns

whether `source` can create remote resources

Since: 3.6

### e_source_get_remote_deletable ()

    gboolean
    e_source_get_remote_deletable (ESource *source);

Returns whether the resource represented by `source` can be deleted from a remote server by calling `e_source_remote_delete()`.

Generally this is only `TRUE` if `source` is a child of an ESource which has an ESourceCollection extension, which means there is an ECollectionBackend in the D-Bus service that can handle delete requests. If `source` does not have this capability, calls to `e_source_remote_delete()` will fail.

#### Parameters

source | an ESource |

#### Returns

whether `source` can delete remote resources

Since: 3.6

### e_source_get_extension ()

    gpointer
    e_source_get_extension (ESource *source,
                            const gchar *extension_name);

Returns an instance of some ESourceExtension subclass which registered itself under `extension_name` . If no such instance exists within `source` , one will be created. It is the caller's responsibility to know which subclass is being returned.

If you just want to test for the existence of an extension within `source` without creating it, use `e_source_has_extension()`.

Extension instances are owned by their ESource and should not be referenced directly. Instead, reference the ESource instance and use this function to fetch the extension instance as needed.

#### Parameters

source | an ESource |
extension_name | an extension name |

#### Returns

an instance of some ESourceExtension subclass.

[type ESourceExtension][transfer none]

Since: 3.6

### e_source_has_extension ()

    gboolean
    e_source_has_extension (ESource *source,
                            const gchar *extension_name);

Checks whether `source` has an ESourceExtension with the given name.

#### Parameters

source | an ESource |
extension_name | an extension name |

#### Returns

`TRUE` if `source` has such an extension, `FALSE` if not

Since: 3.6

### e_source_ref_dbus_object ()

    GDBusObject *
    e_source_ref_dbus_object (ESource *source);

Returns the GDBusObject that was passed to `e_source_new()`.

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

#### Parameters

source | an ESource |

#### Returns

the GDBusObject for `source` , or `NULL`.

[transfer full][nullable]

Since: 3.6

### e_source_ref_main_context ()

    GMainContext *
    e_source_ref_main_context (ESource *source);

Returns the GMainContext on which event sources for `source` are to be attached.

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

#### Parameters

source | an ESource |

#### Returns

a GMainContext.

[transfer full]

Since: 3.6

### e_source_get_display_name ()

    const gchar *
    e_source_get_display_name (ESource *source);

Returns the display name for `source` . Use the display name to represent the ESource in a user interface.

#### Parameters

source | an ESource |

#### Returns

the display name for `source`

Since: 3.6

### e_source_dup_display_name ()

    gchar *
    e_source_dup_display_name (ESource *source);

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

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

#### Parameters

source | an ESource |

#### Returns

a newly-allocated copy of “display-name”

Since: 3.6

### e_source_set_display_name ()

    void
    e_source_set_display_name (ESource *source,
                               const gchar *display_name);

Sets the display name for `source` . The `display_name` argument must be a valid UTF-8 string. Use the display name to represent the ESource in a user interface.

The internal copy of `display_name` is automatically stripped of leading and trailing whitespace.

#### Parameters

source | an ESource |
display_name | a display name |

Since: 3.6

### e_source_dup_secret_label ()

    gchar *
    e_source_dup_secret_label (ESource *source);

Creates a label string based on `source` 's “display-name” for use with SecretItem.

#### Parameters

source | an ESource |

#### Returns

a newly-allocated secret label

Since: 3.12

### e_source_compare_by_display_name ()

    gint
    e_source_compare_by_display_name (ESource *source1,
                                      ESource *source2);

Compares two ESource instances by their display names. Useful for ordering sources in a user interface.

#### Parameters

source1 | the first ESource |
source2 | the second ESource |

#### Returns

a negative value if `source1` compares before `source2` , zero if they compare equal, or a positive value if `source1` compares after `source2`

Since: 3.6

### e_source_to_string ()

    gchar *
    e_source_to_string (ESource *source,
                        gsize *length);

Outputs the current contents of `source` as a key file string. Free the returned string with `g_free()`.

#### Parameters

source | an ESource |
length | return location for the length of the returned string, or `NULL`. | [optional][out]

#### Returns

a newly-allocated string

Since: 3.6

### e_source_parameter_to_key ()

    gchar *
    e_source_parameter_to_key (const gchar *param_name);

Converts a GParamSpec name (e.g. "foo-bar" or "foo_bar") to "CamelCase" for use as a GKeyFile key (e.g. "FooBar").

This function is made public only to aid in account migration. Applications should not need to use this.

#### Parameters

param_name | a GParamSpec name |

Since: 3.6

### e_source_get_connection_status ()

    ESourceConnectionStatus
    e_source_get_connection_status (ESource *source);

Obtain current connection status of the `source` .

#### Parameters

source | an ESource |

#### Returns

Current connection status of the `source` .

Since: 3.16

### e_source_set_connection_status ()

    void
    e_source_set_connection_status (ESource *source,
                                    ESourceConnectionStatus connection_status);

Set's current connection status of the `source` .

#### Parameters

source | an ESource |
connection_status | one of the ESourceConnectionStatus |

Since: 3.16

### e_source_remove_sync ()

    gboolean
    e_source_remove_sync (ESource *source,
                          GCancellable *cancellable,
                          GError **error);

Requests the D-Bus service to delete the key files for `source` and all of its descendants and broadcast their removal to all clients. The `source` must be “removable”.

If an error occurs, the functon will set `error` and return `FALSE`.

#### Parameters

source | the ESource to be removed |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_remove ()

    void
    e_source_remove (ESource *source,
                     GCancellable *cancellable,
                     GAsyncReadyCallback callback,
                     gpointer user_data);

Asynchronously requests the D-Bus service to delete the key files for `source` and all of its descendants and broadcast their removal to all clients. The `source` must be “removable”.

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

#### Parameters

source | the ESource to be removed |
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

### e_source_remove_finish ()

    gboolean
    e_source_remove_finish (ESource *source,
                            GAsyncResult *result,
                            GError **error);

Finishes the operation started with `e_source_remove()`. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

source | the ESource to be removed |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` of failure

Since: 3.6

### e_source_write_sync ()

    gboolean
    e_source_write_sync (ESource *source,
                         GCancellable *cancellable,
                         GError **error);

Submits the current contents of `source` to the D-Bus service to be written to disk and broadcast to other clients. The `source` must be “writable”.

If an error occurs, the functon will set `error` and return `FALSE`.

#### Parameters

source | a writable ESource |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_write ()

    void
    e_source_write (ESource *source,
                    GCancellable *cancellable,
                    GAsyncReadyCallback callback,
                    gpointer user_data);

Asynchronously submits the current contents of `source` to the D-Bus service to be written to disk and broadcast to other clients. The `source` must be “writable”.

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

#### Parameters

source | a writable ESource |
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

### e_source_write_finish ()

    gboolean
    e_source_write_finish (ESource *source,
                           GAsyncResult *result,
                           GError **error);

Finishes the operation started with `e_source_write()`. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

source | a writable ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_remote_create_sync ()

    gboolean
    e_source_remote_create_sync (ESource *source,
                                 ESource *scratch_source,
                                 GCancellable *cancellable,
                                 GError **error);

Creates a new remote resource by picking out relevant details from `scratch_source` . The `scratch_source` must be an ESource with no GDBusObject. The `source` must be “remote-creatable”.

The details required to create the resource vary by ECollectionBackend, but in most cases the `scratch_source` need only define the resource type (address book, calendar, etc.), a display name for the resource, and possibly a server-side path or ID for the resource.

If an error occurs, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
scratch_source | an ESource describing the resource to create |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_remote_create ()

    void
    e_source_remote_create (ESource *source,
                            ESource *scratch_source,
                            GCancellable *cancellable,
                            GAsyncReadyCallback callback,
                            gpointer user_data);

Asynchronously creates a new remote resource by picking out relevant details from `scratch_source` . The `scratch_source` must be an ESource with no GDBusObject. The `source` must be “remote-creatable”.

The details required to create the resource vary by ECollectionBackend, but in most cases the `scratch_source` need only define the resource type (address book, calendar, etc.), a display name for the resource, and possibly a server-side path or ID for the resource.

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

#### Parameters

source | an ESource |
scratch_source | an ESource describing the resource to create |
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

### e_source_remote_create_finish ()

    gboolean
    e_source_remote_create_finish (ESource *source,
                                   GAsyncResult *result,
                                   GError **error);

Finishes the operation started with `e_source_remote_create()`. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_remote_delete_sync ()

    gboolean
    e_source_remote_delete_sync (ESource *source,
                                 GCancellable *cancellable,
                                 GError **error);

Deletes the resource represented by `source` from a remote server. The `source` must be “remote-deletable”. This will also delete the key file for `source` and broadcast its removal to all clients, similar to `e_source_remove_sync()`.

If an error occurs, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_remote_delete ()

    void
    e_source_remote_delete (ESource *source,
                            GCancellable *cancellable,
                            GAsyncReadyCallback callback,
                            gpointer user_data);

Asynchronously deletes the resource represented by `source` from a remote server. The `source` must be “remote-deletable”. This will also delete the key file for `source` and broadcast its removal to all clients, similar to `e_source_remove()`.

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

#### Parameters

source | an ESource |
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

### e_source_remote_delete_finish ()

    gboolean
    e_source_remote_delete_finish (ESource *source,
                                   GAsyncResult *result,
                                   GError **error);

Finishes the operation started with `e_source_remote_delete()`. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.6

### e_source_get_oauth2_access_token_sync ()

    gboolean
    e_source_get_oauth2_access_token_sync (ESource *source,
                                           GCancellable *cancellable,
                                           gchar **out_access_token,
                                           gint *out_expires_in,
                                           GError **error);

Obtains the OAuth 2.0 access token for `source` along with its expiry in seconds from the current time (or 0 if unknown).

Free the returned access token with `g_free()` when finished with it. If an error occurs, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
out_access_token | return location for the access token, or `NULL`. | [optional][out]
out_expires_in | return location for the token expiry, or `NULL`. | [optional][out]
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.8

### e_source_get_oauth2_access_token ()

    void
    e_source_get_oauth2_access_token (ESource *source,
                                      GCancellable *cancellable,
                                      GAsyncReadyCallback callback,
                                      gpointer user_data);

Asynchronously obtains the OAuth 2.0 access token for `source` along with its expiry in seconds from the current time (or 0 if unknown).

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

#### Parameters

source | an ESource |
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.8

### e_source_get_oauth2_access_token_finish ()

    gboolean
    e_source_get_oauth2_access_token_finish
                                   (ESource *source,
                                    GAsyncResult *result,
                                    gchar **out_access_token,
                                    gint *out_expires_in,
                                    GError **error);

Finishes the operation started with `e_source_get_oauth2_access_token()`.

Free the returned access token with `g_free()` when finished with it. If an error occurred, the function will set `error` and return `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
out_access_token | return location for the access token, or `NULL`. | [optional][out]
out_expires_in | return location for the token expiry, or `NULL`. | [optional][out]
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.8

### e_source_store_password_sync ()

    gboolean
    e_source_store_password_sync (ESource *source,
                                  const gchar *password,
                                  gboolean permanently,
                                  GCancellable *cancellable,
                                  GError **error);

Stores a password for `source` . This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

If `permanently` is `TRUE`, the password is stored in the default keyring. Otherwise the password is stored in the memory-only session keyring. If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
password | the password to store |
permanently | store permanently or just for the session |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_store_password ()

    void
    e_source_store_password (ESource *source,
                             const gchar *password,
                             gboolean permanently,
                             GCancellable *cancellable,
                             GAsyncReadyCallback callback,
                             gpointer user_data);

Asynchronously stores a password for `source` . This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

If `permanently` is `TRUE`, the password is stored in the default keyring. Otherwise the password is stored in the memory-only session keyring. If an error occurs, the function sets `error` and returns `FALSE`.

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

#### Parameters

source | an ESource |
password | the password to store |
permanently | store permanently or just for the session |
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.12

### e_source_store_password_finish ()

    gboolean
    e_source_store_password_finish (ESource *source,
                                    GAsyncResult *result,
                                    GError **error);

Finishes the operation started with `e_source_store_password()`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_lookup_password_sync ()

    gboolean
    e_source_lookup_password_sync (ESource *source,
                                   GCancellable *cancellable,
                                   gchar **out_password,
                                   GError **error);

Looks up a password for `source` . Both the default and session keyrings are queried. This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

Note the boolean return value indicates whether the lookup operation itself completed successfully, not whether a password was found. If no password was found, the function will set `out_password` to `NULL` but still return `TRUE`. If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
out_password | return location for the password, or `NULL`. | [out][optional][nullable]
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_lookup_password ()

    void
    e_source_lookup_password (ESource *source,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

Asynchronously looks up a password for `source` . Both the default and session keyrings are queried. This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

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

#### Parameters

source | an ESource |
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.12

### e_source_lookup_password_finish ()

    gboolean
    e_source_lookup_password_finish (ESource *source,
                                     GAsyncResult *result,
                                     gchar **out_password,
                                     GError **error);

Finishes the operation started with `e_source_lookup_password()`.

Note the boolean return value indicates whether the lookup operation itself completed successfully, not whether a password was found. If no password was found, the function will set `out_password` to `NULL` but still return `TRUE`. If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
out_password | return location for the password, or `NULL`. | [out][optional][nullable]
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_delete_password_sync ()

    gboolean
    e_source_delete_password_sync (ESource *source,
                                   GCancellable *cancellable,
                                   GError **error);

Deletes the password for `source` from either the default keyring or session keyring. This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

Note the boolean return value indicates whether the delete operation itself completed successfully, not whether a password was found and deleted. If no password was found, the function will still return `TRUE`. If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_delete_password ()

    void
    e_source_delete_password (ESource *source,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

Asynchronously deletes the password for `source` from either the default keyring or session keyring. This operation does not rely on the registry service and therefore works for any ESource -- registered or "scratch".

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

#### Parameters

source | an ESource |
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.12

### e_source_delete_password_finish ()

    gboolean
    e_source_delete_password_finish (ESource *source,
                                     GAsyncResult *result,
                                     GError **error);

Finishes the operation started with `e_source_delete_password()`.

Note the boolean return value indicates whether the delete operation itself completed successfully, not whether a password was found and deleted. If no password was found, the function will still return `TRUE`. If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.12

### e_source_invoke_credentials_required_sync ()

    gboolean
    e_source_invoke_credentials_required_sync
                                   (ESource *source,
                                    ESourceCredentialsReason reason,
                                    const gchar *certificate_pem,
                                    GTlsCertificateFlags certificate_errors,
                                    const GError *op_error,
                                    GCancellable *cancellable,
                                    GError **error);

Let's the client-side know that credentials are required. The `reason` defines which parameters are used. The client passed the credentials with an `e_source_invoke_authenticate()` call.

The `E_SOURCE_CREDENTIALS_REASON_REQUIRED` is used for the first credentials prompt, when the client can return credentials as stored from the previous success login.

The `E_SOURCE_CREDENTIALS_REASON_REJECTED` is used when the previously used credentials had been rejected by the server. That usually means that the user should be asked to provide/correct the credentials.

The `E_SOURCE_CREDENTIALS_REASON_SSL_FAILED` is used when a secured connection failed due to some server-side certificate issues.

The `E_SOURCE_CREDENTIALS_REASON_ERROR` is used when the server returned an error. It is not possible to connect to it at the moment usually.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
reason | an ESourceCredentialsReason, why the credentials are required |
certificate_pem | PEM-encoded secure connection certificate, or an empty string |
certificate_errors | a bit-or of GTlsCertificateFlags for secure connection certificate |
op_error | a GError with a description of the previous credentials error, or `NULL`. | [nullable]
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_invoke_credentials_required ()

    void
    e_source_invoke_credentials_required (ESource *source,
                                          ESourceCredentialsReason reason,
                                          const gchar *certificate_pem,
                                          GTlsCertificateFlags certificate_errors,
                                          const GError *op_error,
                                          GCancellable *cancellable,
                                          GAsyncReadyCallback callback,
                                          gpointer user_data);

Asynchronously calls the InvokeCredentialsRequired method on the server side, to inform clients that credentials are required.

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

#### Parameters

source | an ESource |
reason | an ESourceCredentialsReason, why the credentials are required |
certificate_pem | PEM-encoded secure connection certificate, or an empty string |
certificate_errors | a bit-or of GTlsCertificateFlags for secure connection certificate |
op_error | a GError with a description of the previous credentials error, or `NULL`. | [nullable]
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.16

### e_source_invoke_credentials_required_finish ()

    gboolean
    e_source_invoke_credentials_required_finish
                                   (ESource *source,
                                    GAsyncResult *result,
                                    GError **error);

Finishes the operation started with `e_source_invoke_credentials_required()`.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_invoke_authenticate_sync ()

    gboolean
    e_source_invoke_authenticate_sync (ESource *source,
                                       const ENamedParameters *credentials,
                                       GCancellable *cancellable,
                                       GError **error);

Calls the InvokeAuthenticate method on the server side, thus the backend knows what credentials to use to connect to its (possibly remote) data store.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
credentials | an ENamedParameters structure with credentials to use; can be `NULL` to use those from the last call. | [nullable]
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_invoke_authenticate ()

    void
    e_source_invoke_authenticate (ESource *source,
                                  const ENamedParameters *credentials,
                                  GCancellable *cancellable,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data);

Asynchronously calls the InvokeAuthenticate method on the server side, thus the backend knows what credentials to use to connect to its (possibly remote) data store.

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

#### Parameters

source | an ESource |
credentials | an ENamedParameters structure with credentials to use; can be `NULL` to use those from the last call. | [nullable]
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.16

### e_source_invoke_authenticate_finish ()

    gboolean
    e_source_invoke_authenticate_finish (ESource *source,
                                         GAsyncResult *result,
                                         GError **error);

Finishes the operation started with `e_source_invoke_authenticate()`.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_emit_credentials_required ()

    void
    e_source_emit_credentials_required (ESource *source,
                                        ESourceCredentialsReason reason,
                                        const gchar *certificate_pem,
                                        GTlsCertificateFlags certificate_errors,
                                        const GError *op_error);

Emits locally (in this process only) the ESource::credentials-required signal with given parameters. That's the difference with `e_source_invoke_credentials_required()`, which calls the signal globally, within each client.

#### Parameters

source | an ESource |
reason | an ESourceCredentialsReason, why the credentials are required |
certificate_pem | PEM-encoded secure connection certificate, or an empty string |
certificate_errors | a bit-or of GTlsCertificateFlags for secure connection certificate |
op_error | a GError with a description of the previous credentials error, or `NULL`. | [nullable]

Since: 3.16

### e_source_get_last_credentials_required_arguments_sync ()

    gboolean
    e_source_get_last_credentials_required_arguments_sync
                                   (ESource *source,
                                    ESourceCredentialsReason *out_reason,
                                    gchar **out_certificate_pem,
                                    GTlsCertificateFlags *out_certificate_errors,
                                    GError **out_op_error,
                                    GCancellable *cancellable,
                                    GError **error);

Retrieves the last used arguments of the 'credentials-required' signal emission. If there was none emitted yet, or a corresponding 'authenitcate' had been emitted already, then the `out_reason` is set to E_SOURCE_CREDENTIALS_REASON_UNKNOWN and the value of other 'out' arguments is set to no values.

If an error occurs, the function sets `error` and returns `FALSE`. The result gchar values should be freed with `g_free()` when no longer needed.

#### Parameters

source | an ESource |
out_reason | an ESourceCredentialsReason, why the credentials are required. | [out]
out_certificate_pem | PEM-encoded secure connection certificate, or an empty string. | [out]
out_certificate_errors | a bit-or of GTlsCertificateFlags for secure connection certificate. | [out]
out_op_error | a GError with a description of the previous credentials error. | [out]
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_get_last_credentials_required_arguments ()

    void
    e_source_get_last_credentials_required_arguments
                                   (ESource *source,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously calls the GetLastCredentialsRequiredArguments method on the server side, to get the last values used for the 'credentials-required' signal. See `e_source_get_last_credentials_required_arguments_sync()` for more information.

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

#### Parameters

source | an ESource |
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.16

### e_source_get_last_credentials_required_arguments_finish ()

    gboolean
    e_source_get_last_credentials_required_arguments_finish
                                   (ESource *source,
                                    GAsyncResult *result,
                                    ESourceCredentialsReason *out_reason,
                                    gchar **out_certificate_pem,
                                    GTlsCertificateFlags *out_certificate_errors,
                                    GError **out_op_error,
                                    GError **error);

Finishes the operation started with `e_source_get_last_credentials_required_arguments()`. See `e_source_get_last_credentials_required_arguments_sync()` for more information about the output arguments.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
out_reason | an ESourceCredentialsReason, why the credentials are required. | [out]
out_certificate_pem | PEM-encoded secure connection certificate, or an empty string. | [out]
out_certificate_errors | a bit-or of GTlsCertificateFlags for secure connection certificate. | [out]
out_op_error | a GError with a description of the previous credentials error. | [out]
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.16

### e_source_unset_last_credentials_required_arguments_sync ()

    gboolean
    e_source_unset_last_credentials_required_arguments_sync
                                   (ESource *source,
                                    GCancellable *cancellable,
                                    GError **error);

Unsets the last used arguments of the 'credentials-required' signal emission.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
cancellable | optional GCancellable object, or `NULL` |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.18

### e_source_unset_last_credentials_required_arguments ()

    void
    e_source_unset_last_credentials_required_arguments
                                   (ESource *source,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously calls the UnsetLastCredentialsRequiredArguments method on the server side, to unset the last values used for the 'credentials-required' signal.

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

#### Parameters

source | an ESource |
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.18

### e_source_unset_last_credentials_required_arguments_finish ()

    gboolean
    e_source_unset_last_credentials_required_arguments_finish
                                   (ESource *source,
                                    GAsyncResult *result,
                                    GError **error);

Finishes the operation started with `e_source_unset_last_credentials_required_arguments()`.

If an error occurs, the function sets `error` and returns `FALSE`.

#### Parameters

source | an ESource |
result | a GAsyncResult |
error | return location for a GError, or `NULL` |

#### Returns

`TRUE` on success, `FALSE` on error

Since: 3.18

## Types and Values

### E_SOURCE_PARAM_SETTING

    #define E_SOURCE_PARAM_SETTING (1 << G_PARAM_USER_SHIFT)

Extends GParamFlags to indicate the GObject property is associated with a key file value. Use this flag when installing GObject properties in ESourceExtension subclasses.

Since: 3.6

### E_SOURCE_CREDENTIAL_USERNAME

    #define E_SOURCE_CREDENTIAL_USERNAME "username"

A name of the named parameter used for usernames in credentials, used to authenticate users with `e_source_invoke_authenticate_sync()` and `e_source_invoke_authenticate()`. The named parameter is optional, different authentication methods can use different names.

Since: 3.16

### E_SOURCE_CREDENTIAL_PASSWORD

    #define E_SOURCE_CREDENTIAL_PASSWORD "password"

A name of the named parameter used for passwords in credentials, used to authenticate users with `e_source_invoke_authenticate_sync()` and `e_source_invoke_authenticate()`. The named parameter is optional, different authentication methods can use different names.

Since: 3.16

### E_SOURCE_CREDENTIAL_SSL_TRUST

    #define E_SOURCE_CREDENTIAL_SSL_TRUST "ssl-trust"

A name of the named parameter used for SSL/TLS trust in credentials, used to authenticate users with `e_source_invoke_authenticate_sync()` and `e_source_invoke_authenticate()`. The named parameter is optional. Its value corresponds to current ESourceWebdav::ssl-trust property, in case the ESource has that extension available. This is required to have up-to-date data on the server side, when the client side just saved the SSL trust change, which might not be propagated into the server (factory) side quickly enough. The key is added into the credentials in `e_source_invoke_authenticate()` automatically, if the corresponding ESource contain a WebDAV extension and the key is not part of the credentials already.

Since: 3.16

### struct ESource

    struct ESource;

Contains only private data that should be read and manipulated using the functions below.

Since: 3.6