Camel.Session.add_service

### Method

# Camel Sessionadd_service

since: 3.2

#### Declaration [src]

    CamelService*
    camel_session_add_service (
      CamelSession* session,
      const gchar* uid,
      const gchar* protocol,
      CamelProviderType type,
      GError** error
    )

#### Description [src]

Instantiates a new `CamelService` for `session`. The `uid` identifies the service for future lookup. The `protocol` indicates which `CamelProvider` holds the `GType` of the `CamelService` subclass to instantiate. The `type` explicitly designates the service as a `CamelStore` or `CamelTransport`.

If the given `uid` has already been added, the existing `CamelService` with that `uid` is returned regardless of whether it agrees with the given `protocol` and `type`.

If no `CamelProvider` is available to handle the given `protocol`, or if the `CamelProvider` does not specify a valid `GType` for `type`, the function sets `error` and returns `NULL`.

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

Available since: 3.2

#### Parameters

`uid`

  Type: `const gchar*`

  A unique identifier string.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`protocol`

  Type: `const gchar*`

  The service protocol.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`type`

  Type: `CamelProviderType`

  The service type.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `CamelService`

A `CamelService` instance, or `NULL` on error.

The caller of the method takes ownership of the returned data, and is responsible for freeing it.