164
backend_authenticate_thread (GSimpleAsyncResult *simple,
166
GCancellable *cancellable)
168
AsyncContext *async_context;
169
GError *error = NULL;
171
async_context = g_simple_async_result_get_op_res_gpointer (simple);
173
e_backend_authenticate_sync (
176
cancellable, &error);
179
g_simple_async_result_take_error (simple, error);
183
backend_authenticate_sync (EBackend *backend,
184
ESourceAuthenticator *auth,
185
GCancellable *cancellable,
189
error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
190
_("%s does not support authentication"),
191
G_OBJECT_TYPE_NAME (backend));
197
backend_authenticate (EBackend *backend,
198
ESourceAuthenticator *auth,
199
GCancellable *cancellable,
200
GAsyncReadyCallback callback,
203
GSimpleAsyncResult *simple;
204
AsyncContext *async_context;
206
async_context = g_slice_new0 (AsyncContext);
207
async_context->auth = g_object_ref (auth);
209
simple = g_simple_async_result_new (
210
G_OBJECT (backend), callback,
211
user_data, backend_authenticate);
213
g_simple_async_result_set_check_cancellable (simple, cancellable);
215
g_simple_async_result_set_op_res_gpointer (
216
simple, async_context, (GDestroyNotify) async_context_free);
218
g_simple_async_result_run_in_thread (
219
simple, backend_authenticate_thread,
220
G_PRIORITY_DEFAULT, cancellable);
222
g_object_unref (simple);
226
backend_authenticate_finish (EBackend *backend,
227
GAsyncResult *result,
230
GSimpleAsyncResult *simple;
232
g_return_val_if_fail (
233
g_simple_async_result_is_valid (
234
result, G_OBJECT (backend),
235
backend_authenticate), FALSE);
237
simple = G_SIMPLE_ASYNC_RESULT (result);
239
/* Assume success unless a GError is set. */
240
return !g_simple_async_result_propagate_error (simple, error);
147
244
e_backend_class_init (EBackendClass *class)
149
246
GObjectClass *object_class;
251
352
return backend->priv->source;
356
* e_backend_authenticate_sync:
357
* @backend: an #EBackend
358
* @auth: an #ESourceAuthenticator
359
* @cancellable: optional #GCancellable object, or %NULL
360
* @error: return location for a #GError, or %NULL
362
* Convenience function providing a consistent authentication interface
363
* for backends running in either the registry service itself or a client
364
* process communicating with the registry service over D-Bus.
366
* Authenticates @backend's #EBackend:source, using @auth to handle
367
* authentication attempts. The @backend and @auth arguments may be one
368
* and the same if @backend implements the #ESourceAuthenticator interface.
369
* The operation loops until authentication is successful or the user aborts
370
* further authentication attempts. If an error occurs, the function will
371
* set @error and return %FALSE.
373
* Returns: %TRUE on success, %FALSE on failure
378
e_backend_authenticate_sync (EBackend *backend,
379
ESourceAuthenticator *auth,
380
GCancellable *cancellable,
383
EBackendClass *class;
385
g_return_val_if_fail (E_IS_BACKEND (backend), FALSE);
386
g_return_val_if_fail (E_IS_SOURCE_AUTHENTICATOR (auth), FALSE);
388
class = E_BACKEND_GET_CLASS (backend);
389
g_return_val_if_fail (class->authenticate_sync != NULL, FALSE);
391
return class->authenticate_sync (backend, auth, cancellable, error);
395
* e_backend_authenticate:
396
* @backend: an #EBackend
397
* @auth: an #ESourceAuthenticator
398
* @cancellable: optional #GCancellable object, or %NULL
399
* @callback: a #GAsyncReadyCallback to call when the request is satisfied
400
* @user_data: data to pass to the callback function
402
* Convenience function providing a consistent authentication interface
403
* for backends running in either the registry service itself or a client
404
* process communicating with the registry service over D-Bus.
406
* Asynchronously authenticates @backend's #EBackend:source, using @auth
407
* to handle authentication attempts. The @backend and @auth arguments may
408
* be one and the same if @backend implements the #ESourceAuthenticator
409
* interface. The operation loops until authentication is succesful or the
410
* user aborts further authentication attempts.
412
* When the operation is finished, @callback will be called. You can then
413
* call e_backend_authenticate_finish() to get the result of the operation.
418
e_backend_authenticate (EBackend *backend,
419
ESourceAuthenticator *auth,
420
GCancellable *cancellable,
421
GAsyncReadyCallback callback,
424
EBackendClass *class;
426
g_return_if_fail (E_IS_BACKEND (backend));
427
g_return_if_fail (E_IS_SOURCE_AUTHENTICATOR (auth));
429
class = E_BACKEND_GET_CLASS (backend);
430
g_return_if_fail (class->authenticate != NULL);
432
class->authenticate (backend, auth, cancellable, callback, user_data);
436
* e_backend_authenticate_finish:
437
* @backend: an #EBackend
438
* @result: a #GAsyncResult
439
* @error: return location for a #GError, or %NULL
441
* Finishes the operation started with e_backend_authenticate(). If
442
* an error occurred, the function will set @error and return %FALSE.
444
* Returns: %TRUE on success, %FALSE on failure
449
e_backend_authenticate_finish (EBackend *backend,
450
GAsyncResult *result,
453
EBackendClass *class;
455
g_return_val_if_fail (E_IS_BACKEND (backend), FALSE);
456
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
458
class = E_BACKEND_GET_CLASS (backend);
459
g_return_val_if_fail (class->authenticate_finish != NULL, FALSE);
461
return class->authenticate_finish (backend, result, error);