### Function

# EBook BookClient connect_sync

since: 3.8

#### Declaration [src]

    EClient*
    e_book_client_connect_sync (
      ESource* source,
      guint32 wait_for_connected_seconds,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

Creates a new `EBookClient` for `source`. If an error occurs, the function will set `error` and return `FALSE`.

Unlike with e_book_client_new(), there is no need to call `e_client_open_sync()` after obtaining the `EBookClient`.

The `wait_for_connected_seconds` argument had been added since 3.16, to let the caller decide how long to wait for the backend to fully connect to its (possibly remote) data store. This is required due to a change in the authentication process, which is fully asynchronous and done on the client side, while not every client is supposed to response to authentication requests. In case the backend will not connect within the set interval, then it is opened in an offline mode. A special value -1 can be used to not wait for the connected state at all.

For error handling convenience, any error message returned by this function will have a descriptive prefix that includes the display name of `source`.

Available since: 3.8

#### Parameters

`source`

  Type: `ESource`

  An `ESource`.

  The data is owned by the caller of the function.

`wait_for_connected_seconds`

  Type: `guint32`

  Timeout, in seconds, to wait for the backend to be fully connected.

`cancellable`

  Type: `GCancellable`

  Optional `GCancellable` object, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`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 function 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: `EBookClient`

A new `EBookClient`, or `NULL` on error.

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