### Virtual Method

# EDataCal CalMetaBackend connect_sync

since: 3.26

#### Declaration [src]

    gboolean
    connect_sync (
      ECalMetaBackend* meta_backend,
      const ENamedParameters* credentials,
      ESourceAuthenticationResult* out_auth_result,
      gchar** out_certificate_pem,
      GTlsCertificateFlags* out_certificate_errors,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

This is called always before any operation which requires a connection to the remote side. It can fail with an #E_CLIENT_ERROR_REPOSITORY_OFFLINE error to indicate that the remote side cannot be currently reached. Other errors are propagated to the caller/client side. This method is not called when the backend is offline.

The descendant should also call `e_cal_backend_set_writable()` after successful connect to the remote side. This value is stored for later use, when being opened offline.

The `credentials` parameter consists of the previously used credentials. It’s always `NULL` with the first connection attempt. To get the credentials, just set the `out_auth_result` to `E_SOURCE_AUTHENTICATION_REQUIRED` for the first time and the function will be called again once the credentials are available. See the documentation of `ESourceAuthenticationResult` for other available results.

The out parameters are passed to `e_backend_schedule_credentials_required()` and are ignored when the descendant returns `TRUE`, aka they are used only if the connection fails. The `out_certificate_pem` and `out_certificate_errors` should be used together and they can be left untouched if the failure reason was not related to certificate. Use `out_auth_result` `E_SOURCE_AUTHENTICATION_UNKNOWN` to indicate other error than `credentials` error, otherwise the `error` is used according to `out_auth_result` value.

It is mandatory to implement this virtual method by the descendant.

Available since: 3.26

#### Parameters

`credentials`

  Type: `ENamedParameters`

  An `ENamedParameters` with previously used credentials, or `NULL`.

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

`out_auth_result`

  Type: `ESourceAuthenticationResult`

  An `ESourceAuthenticationResult` with an authentication result.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.

`out_certificate_pem`

  Type: `gchar**`

  A PEM encoded certificate on failure, or `NULL`.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

`out_certificate_errors`

  Type: `GTlsCertificateFlags`

  A `GTlsCertificateFlags` on failure, or 0.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.

`cancellable`

  Type: `GCancellable`

  Optional `GCancellable` object, or `NULL`.

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

`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 virtual 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: `gboolean`

Whether succeeded.