4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
18 * Copyright (C) 2011 Red Hat, Inc. (www.redhat.com)
22 /* TODO The next time we have a good excuse to break libedataserver's API,
23 * I'd like to purge all the deprecated cruft here and convert EClient
24 * from a GObjectClass to a GTypeInterface, implemented by EBookClient
25 * and ECalClient. Then we could just bind the "online", "readonly"
26 * and "capabilities" properties to equivalent GDBusProxy properties
27 * and kill e-client-private.h. Would simplify things. --mbarnes
34 #include <glib/gi18n-lib.h>
37 #include <libedataserver/e-data-server-util.h>
39 #include "e-gdbus-marshallers.h"
42 #include "e-client-private.h"
44 #define E_CLIENT_GET_PRIVATE(obj) \
45 (G_TYPE_INSTANCE_GET_PRIVATE \
46 ((obj), E_TYPE_CLIENT, EClientPrivate))
48 typedef struct _AsyncContext AsyncContext;
50 struct _EClientPrivate {
57 GMainContext *main_context;
60 struct _AsyncContext {
64 gboolean only_if_exists;
81 BACKEND_PROPERTY_CHANGED,
85 static guint signals[LAST_SIGNAL];
87 G_DEFINE_ABSTRACT_TYPE (EClient, e_client, G_TYPE_OBJECT)
90 async_context_free (AsyncContext *async_context)
92 g_free (async_context->capabilities);
93 g_free (async_context->prop_name);
94 g_free (async_context->prop_value);
96 g_slice_free (AsyncContext, async_context);
100 * Well-known client backend properties, which are common for each #EClient:
101 * @CLIENT_BACKEND_PROPERTY_OPENED: Is set to "TRUE" or "FALSE" depending
102 * whether the backend is fully opened.
103 * @CLIENT_BACKEND_PROPERTY_OPENING: Is set to "TRUE" or "FALSE" depending
104 * whether the backend is processing its opening phase.
105 * @CLIENT_BACKEND_PROPERTY_ONLINE: Is set to "TRUE" or "FALSE" depending
106 * on the backend's loaded state. See also e_client_is_online().
107 * @CLIENT_BACKEND_PROPERTY_READONLY: Is set to "TRUE" or "FALSE" depending
108 * on the backend's readonly state. See also e_client_is_readonly().
109 * @CLIENT_BACKEND_PROPERTY_CACHE_DIR: Local folder with cached data used
111 * @CLIENT_BACKEND_PROPERTY_CAPABILITIES: Retrieves comma-separated list
112 * of capabilities supported by the backend. Preferred method of retreiving
113 * and working with capabilities is e_client_get_capabilities() and
114 * e_client_check_capability().
117 G_DEFINE_QUARK (e-client-error-quark, e_client_error)
120 * e_client_error_to_string:
122 * FIXME: Document me.
127 e_client_error_to_string (EClientError code)
130 case E_CLIENT_ERROR_INVALID_ARG:
131 return _("Invalid argument");
132 case E_CLIENT_ERROR_BUSY:
133 return _("Backend is busy");
134 case E_CLIENT_ERROR_SOURCE_NOT_LOADED:
135 return _("Source not loaded");
136 case E_CLIENT_ERROR_SOURCE_ALREADY_LOADED:
137 return _("Source already loaded");
138 case E_CLIENT_ERROR_AUTHENTICATION_FAILED:
139 return _("Authentication failed");
140 case E_CLIENT_ERROR_AUTHENTICATION_REQUIRED:
141 return _("Authentication required");
142 case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
143 return _("Repository offline");
144 case E_CLIENT_ERROR_OFFLINE_UNAVAILABLE:
145 /* Translators: This means that the EClient does not support offline mode, or
146 * it's not set to by a user, thus it is unavailable while user is not connected. */
147 return _("Offline unavailable");
148 case E_CLIENT_ERROR_PERMISSION_DENIED:
149 return _("Permission denied");
150 case E_CLIENT_ERROR_CANCELLED:
151 return _("Cancelled");
152 case E_CLIENT_ERROR_COULD_NOT_CANCEL:
153 return _("Could not cancel");
154 case E_CLIENT_ERROR_NOT_SUPPORTED:
155 return _("Not supported");
156 case E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD:
157 return _("Unsupported authentication method");
158 case E_CLIENT_ERROR_TLS_NOT_AVAILABLE:
159 return _("TLS not available");
160 case E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED:
161 return _("Search size limit exceeded");
162 case E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED:
163 return _("Search time limit exceeded");
164 case E_CLIENT_ERROR_INVALID_QUERY:
165 return _("Invalid query");
166 case E_CLIENT_ERROR_QUERY_REFUSED:
167 return _("Query refused");
168 case E_CLIENT_ERROR_DBUS_ERROR:
169 return _("D-Bus error");
170 case E_CLIENT_ERROR_OTHER_ERROR:
171 return _("Other error");
172 case E_CLIENT_ERROR_NOT_OPENED:
173 return _("Backend is not opened yet");
174 case E_CLIENT_ERROR_OUT_OF_SYNC:
175 return _("Object is out of sync");
178 return _("Unknown error");
182 * e_client_error_create:
183 * @code: an #EClientError code to create
184 * @custom_msg: custom message to use for the error; can be %NULL
186 * Returns: a new #GError containing an E_CLIENT_ERROR of the given
187 * @code. If the @custom_msg is NULL, then the error message is
188 * the one returned from e_client_error_to_string() for the @code,
189 * otherwise the given message is used.
191 * Returned pointer should be freed with g_error_free().
195 * Deprecated: 3.8: Just use the #GError API directly.
198 e_client_error_create (EClientError code,
199 const gchar *custom_msg)
201 return g_error_new_literal (E_CLIENT_ERROR, code, custom_msg ? custom_msg : e_client_error_to_string (code));
205 client_set_source (EClient *client,
208 g_return_if_fail (E_IS_SOURCE (source));
209 g_return_if_fail (client->priv->source == NULL);
211 client->priv->source = g_object_ref (source);
215 client_set_property (GObject *object,
220 switch (property_id) {
222 e_client_set_online (
224 g_value_get_boolean (value));
230 g_value_get_object (value));
234 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
238 client_get_property (GObject *object,
243 switch (property_id) {
244 case PROP_CAPABILITIES:
245 g_value_set_pointer (
247 (gpointer) e_client_get_capabilities (
251 case PROP_MAIN_CONTEXT:
254 e_client_ref_main_context (
259 g_value_set_boolean (
266 g_value_set_boolean (
273 g_value_set_boolean (
275 e_client_is_readonly (
282 e_client_get_source (
287 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
291 client_dispose (GObject *object)
293 EClientPrivate *priv;
295 priv = E_CLIENT_GET_PRIVATE (object);
297 if (priv->main_context != NULL) {
298 g_main_context_unref (priv->main_context);
299 priv->main_context = NULL;
302 g_clear_object (&priv->source);
304 /* Chain up to parent's dispose() method. */
305 G_OBJECT_CLASS (e_client_parent_class)->dispose (object);
309 client_finalize (GObject *object)
311 EClientPrivate *priv;
313 priv = E_CLIENT_GET_PRIVATE (object);
315 g_slist_free_full (priv->capabilities, (GDestroyNotify) g_free);
317 g_rec_mutex_clear (&priv->prop_mutex);
319 /* Chain up to parent's finalize() method. */
320 G_OBJECT_CLASS (e_client_parent_class)->finalize (object);
324 client_unwrap_dbus_error (EClient *client,
328 /* This method is deprecated. Make it a no-op. */
330 if (out_error != NULL)
331 *out_error = dbus_error;
334 /* Helper for client_retrieve_capabilities() */
336 client_retrieve_capabilities_thread (GSimpleAsyncResult *simple,
337 GObject *source_object,
338 GCancellable *cancellable)
340 AsyncContext *async_context;
341 GError *error = NULL;
343 async_context = g_simple_async_result_get_op_res_gpointer (simple);
345 e_client_retrieve_capabilities_sync (
346 E_CLIENT (source_object),
347 &async_context->capabilities,
348 cancellable, &error);
351 g_simple_async_result_take_error (simple, error);
355 client_retrieve_capabilities (EClient *client,
356 GCancellable *cancellable,
357 GAsyncReadyCallback callback,
360 GSimpleAsyncResult *simple;
361 AsyncContext *async_context;
363 async_context = g_slice_new0 (AsyncContext);
365 simple = g_simple_async_result_new (
366 G_OBJECT (client), callback,
367 user_data, client_retrieve_capabilities);
369 g_simple_async_result_set_check_cancellable (simple, cancellable);
371 g_simple_async_result_set_op_res_gpointer (
372 simple, async_context, (GDestroyNotify) async_context_free);
374 g_simple_async_result_run_in_thread (
375 simple, client_retrieve_capabilities_thread,
376 G_PRIORITY_DEFAULT, cancellable);
378 g_object_unref (simple);
382 client_retrieve_capabilities_finish (EClient *client,
383 GAsyncResult *result,
384 gchar **capabilities,
387 GSimpleAsyncResult *simple;
388 AsyncContext *async_context;
390 g_return_val_if_fail (
391 g_simple_async_result_is_valid (
392 result, G_OBJECT (client),
393 client_retrieve_capabilities), FALSE);
395 simple = G_SIMPLE_ASYNC_RESULT (result);
396 async_context = g_simple_async_result_get_op_res_gpointer (simple);
398 if (g_simple_async_result_propagate_error (simple, error))
401 g_return_val_if_fail (async_context->capabilities != NULL, FALSE);
403 if (capabilities != NULL) {
404 *capabilities = async_context->capabilities;
405 async_context->capabilities = NULL;
412 client_retrieve_capabilities_sync (EClient *client,
413 gchar **capabilities,
414 GCancellable *cancellable,
417 return e_client_get_backend_property_sync (
418 client, CLIENT_BACKEND_PROPERTY_CAPABILITIES,
419 capabilities, cancellable, error);
422 /* Helper for client_get_backend_property() */
424 client_get_backend_property_thread (GSimpleAsyncResult *simple,
425 GObject *source_object,
426 GCancellable *cancellable)
428 AsyncContext *async_context;
429 GError *error = NULL;
431 async_context = g_simple_async_result_get_op_res_gpointer (simple);
433 e_client_get_backend_property_sync (
434 E_CLIENT (source_object),
435 async_context->prop_name,
436 &async_context->prop_value,
437 cancellable, &error);
440 g_simple_async_result_take_error (simple, error);
444 client_get_backend_property (EClient *client,
445 const gchar *prop_name,
446 GCancellable *cancellable,
447 GAsyncReadyCallback callback,
450 GSimpleAsyncResult *simple;
451 AsyncContext *async_context;
453 async_context = g_slice_new0 (AsyncContext);
454 async_context->prop_name = g_strdup (prop_name);
456 simple = g_simple_async_result_new (
457 G_OBJECT (client), callback,
458 user_data, client_get_backend_property);
460 g_simple_async_result_set_check_cancellable (simple, cancellable);
462 g_simple_async_result_set_op_res_gpointer (
463 simple, async_context, (GDestroyNotify) async_context_free);
465 g_simple_async_result_run_in_thread (
466 simple, client_get_backend_property_thread,
467 G_PRIORITY_DEFAULT, cancellable);
469 g_object_unref (simple);
473 client_get_backend_property_finish (EClient *client,
474 GAsyncResult *result,
478 GSimpleAsyncResult *simple;
479 AsyncContext *async_context;
481 g_return_val_if_fail (
482 g_simple_async_result_is_valid (
483 result, G_OBJECT (client),
484 client_get_backend_property), FALSE);
486 simple = G_SIMPLE_ASYNC_RESULT (result);
487 async_context = g_simple_async_result_get_op_res_gpointer (simple);
489 if (g_simple_async_result_propagate_error (simple, error))
492 g_return_val_if_fail (async_context->prop_value != NULL, FALSE);
494 if (prop_value != NULL) {
495 *prop_value = async_context->prop_value;
496 async_context->prop_value = NULL;
502 /* Helper for client_set_backend_property() */
504 client_set_backend_property_thread (GSimpleAsyncResult *simple,
505 GObject *source_object,
506 GCancellable *cancellable)
508 AsyncContext *async_context;
509 GError *error = NULL;
511 async_context = g_simple_async_result_get_op_res_gpointer (simple);
513 e_client_set_backend_property_sync (
514 E_CLIENT (source_object),
515 async_context->prop_name,
516 async_context->prop_value,
517 cancellable, &error);
520 g_simple_async_result_take_error (simple, error);
524 client_set_backend_property (EClient *client,
525 const gchar *prop_name,
526 const gchar *prop_value,
527 GCancellable *cancellable,
528 GAsyncReadyCallback callback,
531 GSimpleAsyncResult *simple;
532 AsyncContext *async_context;
534 async_context = g_slice_new0 (AsyncContext);
535 async_context->prop_name = g_strdup (prop_name);
536 async_context->prop_value = g_strdup (prop_value);
538 simple = g_simple_async_result_new (
539 G_OBJECT (client), callback,
540 user_data, client_set_backend_property);
542 g_simple_async_result_set_check_cancellable (simple, cancellable);
544 g_simple_async_result_set_op_res_gpointer (
545 simple, async_context, (GDestroyNotify) async_context_free);
547 g_simple_async_result_run_in_thread (
548 simple, client_set_backend_property_thread,
549 G_PRIORITY_DEFAULT, cancellable);
551 g_object_unref (simple);
555 client_set_backend_property_finish (EClient *client,
556 GAsyncResult *result,
559 GSimpleAsyncResult *simple;
561 g_return_val_if_fail (
562 g_simple_async_result_is_valid (
563 result, G_OBJECT (client),
564 client_set_backend_property), FALSE);
566 simple = G_SIMPLE_ASYNC_RESULT (result);
568 /* Assume success unless a GError is set. */
569 return !g_simple_async_result_propagate_error (simple, error);
572 /* Helper for client_open() */
574 client_open_thread (GSimpleAsyncResult *simple,
575 GObject *source_object,
576 GCancellable *cancellable)
578 AsyncContext *async_context;
579 GError *error = NULL;
581 async_context = g_simple_async_result_get_op_res_gpointer (simple);
584 E_CLIENT (source_object),
585 async_context->only_if_exists,
586 cancellable, &error);
589 g_simple_async_result_take_error (simple, error);
593 client_open (EClient *client,
594 gboolean only_if_exists,
595 GCancellable *cancellable,
596 GAsyncReadyCallback callback,
599 GSimpleAsyncResult *simple;
600 AsyncContext *async_context;
602 async_context = g_slice_new0 (AsyncContext);
603 async_context->only_if_exists = only_if_exists;
605 simple = g_simple_async_result_new (
606 G_OBJECT (client), callback, user_data, client_open);
608 g_simple_async_result_set_check_cancellable (simple, cancellable);
610 g_simple_async_result_set_op_res_gpointer (
611 simple, async_context, (GDestroyNotify) async_context_free);
613 g_simple_async_result_run_in_thread (
614 simple, client_open_thread,
615 G_PRIORITY_DEFAULT, cancellable);
617 g_object_unref (simple);
621 client_open_finish (EClient *client,
622 GAsyncResult *result,
625 GSimpleAsyncResult *simple;
627 g_return_val_if_fail (
628 g_simple_async_result_is_valid (
629 result, G_OBJECT (client), client_open), FALSE);
631 simple = G_SIMPLE_ASYNC_RESULT (result);
633 /* Assume success unless a GError is set. */
634 return !g_simple_async_result_propagate_error (simple, error);
637 /* Helper for client_remove() */
639 client_remove_thread (GSimpleAsyncResult *simple,
640 GObject *source_object,
641 GCancellable *cancellable)
643 GError *error = NULL;
645 e_client_remove_sync (
646 E_CLIENT (source_object), cancellable, &error);
649 g_simple_async_result_take_error (simple, error);
653 client_remove (EClient *client,
654 GCancellable *cancellable,
655 GAsyncReadyCallback callback,
658 GSimpleAsyncResult *simple;
660 simple = g_simple_async_result_new (
661 G_OBJECT (client), callback, user_data, client_remove);
663 g_simple_async_result_set_check_cancellable (simple, cancellable);
665 g_simple_async_result_run_in_thread (
666 simple, client_remove_thread,
667 G_PRIORITY_DEFAULT, cancellable);
669 g_object_unref (simple);
673 client_remove_finish (EClient *client,
674 GAsyncResult *result,
677 GSimpleAsyncResult *simple;
679 g_return_val_if_fail (
680 g_simple_async_result_is_valid (
681 result, G_OBJECT (client), client_remove), FALSE);
683 simple = G_SIMPLE_ASYNC_RESULT (result);
685 /* Assume success unless a GError is set. */
686 return !g_simple_async_result_propagate_error (simple, error);
690 client_remove_sync (EClient *client,
691 GCancellable *cancellable,
696 source = e_client_get_source (client);
698 return e_source_remove_sync (source, cancellable, error);
701 /* Helper for client_refresh() */
703 client_refresh_thread (GSimpleAsyncResult *simple,
704 GObject *source_object,
705 GCancellable *cancellable)
707 GError *error = NULL;
709 e_client_refresh_sync (
710 E_CLIENT (source_object), cancellable, &error);
713 g_simple_async_result_take_error (simple, error);
717 client_refresh (EClient *client,
718 GCancellable *cancellable,
719 GAsyncReadyCallback callback,
722 GSimpleAsyncResult *simple;
724 simple = g_simple_async_result_new (
725 G_OBJECT (client), callback, user_data, client_refresh);
727 g_simple_async_result_set_check_cancellable (simple, cancellable);
729 g_simple_async_result_run_in_thread (
730 simple, client_refresh_thread,
731 G_PRIORITY_DEFAULT, cancellable);
733 g_object_unref (simple);
737 client_refresh_finish (EClient *client,
738 GAsyncResult *result,
741 GSimpleAsyncResult *simple;
743 g_return_val_if_fail (
744 g_simple_async_result_is_valid (
745 result, G_OBJECT (client), client_refresh), FALSE);
747 simple = G_SIMPLE_ASYNC_RESULT (result);
749 /* Assume success unless a GError is set. */
750 return !g_simple_async_result_propagate_error (simple, error);
754 e_client_class_init (EClientClass *class)
756 GObjectClass *object_class;
758 g_type_class_add_private (class, sizeof (EClientPrivate));
760 object_class = G_OBJECT_CLASS (class);
761 object_class->set_property = client_set_property;
762 object_class->get_property = client_get_property;
763 object_class->dispose = client_dispose;
764 object_class->finalize = client_finalize;
766 class->unwrap_dbus_error = client_unwrap_dbus_error;
767 class->retrieve_capabilities = client_retrieve_capabilities;
768 class->retrieve_capabilities_finish = client_retrieve_capabilities_finish;
769 class->retrieve_capabilities_sync = client_retrieve_capabilities_sync;
770 class->get_backend_property = client_get_backend_property;
771 class->get_backend_property_finish = client_get_backend_property_finish;
772 class->set_backend_property = client_set_backend_property;
773 class->set_backend_property_finish = client_set_backend_property_finish;
774 class->open = client_open;
775 class->open_finish = client_open_finish;
776 class->remove = client_remove;
777 class->remove_finish = client_remove_finish;
778 class->remove_sync = client_remove_sync;
779 class->refresh = client_refresh;
780 class->refresh_finish = client_refresh_finish;
782 g_object_class_install_property (
785 g_param_spec_pointer (
790 G_PARAM_STATIC_STRINGS));
792 g_object_class_install_property (
798 "The main loop context on "
799 "which to attach event sources",
802 G_PARAM_STATIC_STRINGS));
804 g_object_class_install_property (
807 g_param_spec_boolean (
813 G_PARAM_STATIC_STRINGS));
815 g_object_class_install_property (
818 g_param_spec_boolean (
824 G_PARAM_STATIC_STRINGS));
826 g_object_class_install_property (
829 g_param_spec_boolean (
835 G_PARAM_STATIC_STRINGS));
837 g_object_class_install_property (
840 g_param_spec_object (
846 G_PARAM_CONSTRUCT_ONLY |
847 G_PARAM_STATIC_STRINGS));
852 * Deprecated: 3.8: This signal is no longer emitted.
854 signals[OPENED] = g_signal_new (
856 G_OBJECT_CLASS_TYPE (class),
859 G_STRUCT_OFFSET (EClientClass, opened),
861 g_cclosure_marshal_VOID__BOXED,
865 signals[BACKEND_ERROR] = g_signal_new (
867 G_OBJECT_CLASS_TYPE (class),
869 G_STRUCT_OFFSET (EClientClass, backend_error),
871 g_cclosure_marshal_VOID__STRING,
875 signals[BACKEND_DIED] = g_signal_new (
877 G_OBJECT_CLASS_TYPE (class),
879 G_STRUCT_OFFSET (EClientClass, backend_died),
881 g_cclosure_marshal_VOID__VOID,
884 signals[BACKEND_PROPERTY_CHANGED] = g_signal_new (
885 "backend-property-changed",
886 G_OBJECT_CLASS_TYPE (class),
888 G_STRUCT_OFFSET (EClientClass, backend_property_changed),
890 e_gdbus_marshallers_VOID__STRING_STRING,
891 G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
895 e_client_init (EClient *client)
897 client->priv = E_CLIENT_GET_PRIVATE (client);
899 client->priv->readonly = TRUE;
900 client->priv->main_context = g_main_context_ref_thread_default ();
902 g_rec_mutex_init (&client->priv->prop_mutex);
906 * e_client_get_source:
907 * @client: an #EClient
909 * Get the #ESource that this client has assigned.
911 * Returns: (transfer none): The source.
916 e_client_get_source (EClient *client)
918 g_return_val_if_fail (E_IS_CLIENT (client), NULL);
920 return client->priv->source;
924 client_ensure_capabilities (EClient *client)
926 gchar *capabilities = NULL;
928 g_return_if_fail (E_IS_CLIENT (client));
930 if (client->priv->capabilities != NULL)
933 /* Despite appearances this function does not actually block. */
934 e_client_get_backend_property_sync (
935 client, CLIENT_BACKEND_PROPERTY_CAPABILITIES,
936 &capabilities, NULL, NULL);
937 e_client_set_capabilities (client, capabilities);
938 g_free (capabilities);
942 * e_client_get_capabilities:
943 * @client: an #EClient
945 * Get list of strings with capabilities advertised by a backend.
946 * This list, together with inner strings, is owned by the @client.
947 * To check for individual capabilities use e_client_check_capability().
949 * Returns: (element-type utf8) (transfer none): #GSList of const strings
955 e_client_get_capabilities (EClient *client)
957 g_return_val_if_fail (E_IS_CLIENT (client), NULL);
959 client_ensure_capabilities (client);
961 return client->priv->capabilities;
965 * e_client_ref_main_context:
966 * @client: an #EClient
968 * Returns the #GMainContext on which event sources for @client are to
971 * The returned #GMainContext is referenced for thread-safety and must be
972 * unreferenced with g_main_context_unref() when finished with it.
974 * Returns: (transfer full): a #GMainContext
979 e_client_ref_main_context (EClient *client)
981 g_return_val_if_fail (E_IS_CLIENT (client), NULL);
983 return g_main_context_ref (client->priv->main_context);
987 * e_client_check_capability:
988 * @client: an #EClient
989 * @capability: a capability
991 * Check if backend supports particular capability.
992 * To get all capabilities use e_client_get_capabilities().
994 * Returns: #GSList of const strings of capabilities
999 e_client_check_capability (EClient *client,
1000 const gchar *capability)
1004 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1005 g_return_val_if_fail (capability, FALSE);
1007 g_rec_mutex_lock (&client->priv->prop_mutex);
1009 client_ensure_capabilities (client);
1011 for (iter = client->priv->capabilities; iter; iter = g_slist_next (iter)) {
1012 const gchar *cap = iter->data;
1014 if (cap && g_ascii_strcasecmp (cap, capability) == 0) {
1015 g_rec_mutex_unlock (&client->priv->prop_mutex);
1020 g_rec_mutex_unlock (&client->priv->prop_mutex);
1026 * e_client_check_refresh_supported:
1027 * @client: A client.
1029 * Checks whether a client supports explicit refreshing
1030 * (see e_client_refresh()).
1032 * Returns: TRUE if the client supports refreshing, FALSE otherwise.
1037 e_client_check_refresh_supported (EClient *client)
1039 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1041 return e_client_check_capability (client, "refresh-supported");
1044 /* capabilities - comma-separated list of capabilities; can be NULL to unset */
1046 e_client_set_capabilities (EClient *client,
1047 const gchar *capabilities)
1049 g_return_if_fail (E_IS_CLIENT (client));
1051 g_rec_mutex_lock (&client->priv->prop_mutex);
1053 g_slist_foreach (client->priv->capabilities, (GFunc) g_free, NULL);
1054 g_slist_free (client->priv->capabilities);
1055 client->priv->capabilities = e_client_util_parse_comma_strings (capabilities);
1057 g_rec_mutex_unlock (&client->priv->prop_mutex);
1059 g_object_notify (G_OBJECT (client), "capabilities");
1063 * e_client_is_readonly:
1064 * @client: an #EClient
1066 * Check if this @client is read-only.
1068 * Returns: %TRUE if this @client is read-only, otherwise %FALSE.
1073 e_client_is_readonly (EClient *client)
1075 g_return_val_if_fail (E_IS_CLIENT (client), TRUE);
1077 return client->priv->readonly;
1081 e_client_set_readonly (EClient *client,
1084 g_return_if_fail (E_IS_CLIENT (client));
1086 g_rec_mutex_lock (&client->priv->prop_mutex);
1087 if (client->priv->readonly == readonly) {
1088 g_rec_mutex_unlock (&client->priv->prop_mutex);
1092 client->priv->readonly = readonly;
1094 g_rec_mutex_unlock (&client->priv->prop_mutex);
1096 g_object_notify (G_OBJECT (client), "readonly");
1100 * e_client_is_online:
1101 * @client: an #EClient
1103 * Check if this @client is connected.
1105 * Returns: %TRUE if this @client is connected, otherwise %FALSE.
1110 e_client_is_online (EClient *client)
1112 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1114 return client->priv->online;
1118 e_client_set_online (EClient *client,
1121 g_return_if_fail (E_IS_CLIENT (client));
1123 /* newly connected/disconnected => make sure capabilities will be correct */
1124 e_client_set_capabilities (client, NULL);
1126 g_rec_mutex_lock (&client->priv->prop_mutex);
1127 if (client->priv->online == is_online) {
1128 g_rec_mutex_unlock (&client->priv->prop_mutex);
1132 client->priv->online = is_online;
1134 g_rec_mutex_unlock (&client->priv->prop_mutex);
1136 g_object_notify (G_OBJECT (client), "online");
1140 * e_client_is_opened:
1141 * @client: an #EClient
1143 * Check if this @client is fully opened. This includes
1144 * everything from e_client_open() call up to the authentication,
1145 * if required by a backend. Client cannot do any other operation
1146 * during the opening phase except of authenticate or cancel it.
1147 * Every other operation results in an %E_CLIENT_ERROR_BUSY error.
1149 * Returns: always %TRUE
1153 * Deprecated: 3.8: Clients don't need to care if they're fully opened
1154 * anymore. This function always returns %TRUE.
1157 e_client_is_opened (EClient *client)
1159 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1165 * e_client_cancel_all:
1166 * @client: an #EClient
1168 * Cancels all pending operations started on @client.
1172 * Deprecated: 3.8: The function no longer does anything.
1175 e_client_cancel_all (EClient *client)
1181 * e_client_retrieve_capabilities:
1182 * @client: an #EClient
1183 * @cancellable: a #GCancellable; can be %NULL
1184 * @callback: callback to call when a result is ready
1185 * @user_data: user data for the @callback
1187 * Initiates retrieval of capabilities on the @client. This is usually
1188 * required only once, after the @client is opened. The returned value
1189 * is cached and any subsequent call of e_client_get_capabilities() and
1190 * e_client_check_capability() is using the cached value.
1191 * The call is finished by e_client_retrieve_capabilities_finish()
1192 * from the @callback.
1196 * Deprecated: 3.8: Use e_client_get_capabilities() instead.
1199 e_client_retrieve_capabilities (EClient *client,
1200 GCancellable *cancellable,
1201 GAsyncReadyCallback callback,
1204 EClientClass *class;
1206 g_return_if_fail (E_IS_CLIENT (client));
1207 g_return_if_fail (callback != NULL);
1209 class = E_CLIENT_GET_CLASS (client);
1210 g_return_if_fail (class != NULL);
1211 g_return_if_fail (class->retrieve_capabilities != NULL);
1213 class->retrieve_capabilities (client, cancellable, callback, user_data);
1217 * e_client_retrieve_capabilities_finish:
1218 * @client: an #EClient
1219 * @result: a #GAsyncResult
1220 * @capabilities: (out): Comma-separated list of capabilities of the @client
1221 * @error: (out): a #GError to set an error, if any
1223 * Finishes previous call of e_client_retrieve_capabilities().
1224 * Returned value of @capabilities should be freed with g_free(),
1225 * when no longer needed.
1227 * Returns: %TRUE if successful, %FALSE otherwise.
1231 * Deprecated: 3.8: Use e_client_get_capabilities() instead.
1234 e_client_retrieve_capabilities_finish (EClient *client,
1235 GAsyncResult *result,
1236 gchar **capabilities,
1239 EClientClass *class;
1242 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1243 g_return_val_if_fail (capabilities != NULL, FALSE);
1245 class = E_CLIENT_GET_CLASS (client);
1246 g_return_val_if_fail (class != NULL, FALSE);
1247 g_return_val_if_fail (class->retrieve_capabilities_finish != NULL, FALSE);
1249 *capabilities = NULL;
1250 res = class->retrieve_capabilities_finish (client, result, capabilities, error);
1252 e_client_set_capabilities (client, res ? *capabilities : NULL);
1258 * e_client_retrieve_capabilities_sync:
1259 * @client: an #EClient
1260 * @capabilities: (out): Comma-separated list of capabilities of the @client
1261 * @cancellable: a #GCancellable; can be %NULL
1262 * @error: (out): a #GError to set an error, if any
1264 * Initiates retrieval of capabilities on the @client. This is usually
1265 * required only once, after the @client is opened. The returned value
1266 * is cached and any subsequent call of e_client_get_capabilities() and
1267 * e_client_check_capability() is using the cached value. Returned value
1268 * of @capabilities should be freed with g_free(), when no longer needed.
1270 * Returns: %TRUE if successful, %FALSE otherwise.
1274 * Deprecated: 3.8: Use e_client_get_capabilities() instead.
1277 e_client_retrieve_capabilities_sync (EClient *client,
1278 gchar **capabilities,
1279 GCancellable *cancellable,
1282 EClientClass *class;
1283 gboolean res = FALSE;
1285 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1286 g_return_val_if_fail (capabilities != NULL, FALSE);
1288 class = E_CLIENT_GET_CLASS (client);
1289 g_return_val_if_fail (class != NULL, FALSE);
1290 g_return_val_if_fail (class->retrieve_capabilities_sync != NULL, FALSE);
1292 *capabilities = NULL;
1293 res = class->retrieve_capabilities_sync (client, capabilities, cancellable, error);
1295 e_client_set_capabilities (client, res ? *capabilities : NULL);
1301 * e_client_get_backend_property:
1302 * @client: an #EClient
1303 * @prop_name: property name, whose value to retrieve; cannot be %NULL
1304 * @cancellable: a #GCancellable; can be %NULL
1305 * @callback: callback to call when a result is ready
1306 * @user_data: user data for the @callback
1308 * Queries @client's backend for a property of name @prop_name.
1309 * The call is finished by e_client_get_backend_property_finish()
1310 * from the @callback.
1315 e_client_get_backend_property (EClient *client,
1316 const gchar *prop_name,
1317 GCancellable *cancellable,
1318 GAsyncReadyCallback callback,
1321 EClientClass *class;
1323 g_return_if_fail (callback != NULL);
1324 g_return_if_fail (E_IS_CLIENT (client));
1325 g_return_if_fail (prop_name != NULL);
1327 class = E_CLIENT_GET_CLASS (client);
1328 g_return_if_fail (class != NULL);
1329 g_return_if_fail (class->get_backend_property != NULL);
1331 class->get_backend_property (client, prop_name, cancellable, callback, user_data);
1335 * e_client_get_backend_property_finish:
1336 * @client: an #EClient
1337 * @result: a #GAsyncResult
1338 * @prop_value: (out): Retrieved backend property value; cannot be %NULL
1339 * @error: (out): a #GError to set an error, if any
1341 * Finishes previous call of e_client_get_backend_property().
1343 * Returns: %TRUE if successful, %FALSE otherwise.
1348 e_client_get_backend_property_finish (EClient *client,
1349 GAsyncResult *result,
1353 EClientClass *class;
1355 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1356 g_return_val_if_fail (prop_value != NULL, FALSE);
1358 class = E_CLIENT_GET_CLASS (client);
1359 g_return_val_if_fail (class != NULL, FALSE);
1360 g_return_val_if_fail (class->get_backend_property_finish != NULL, FALSE);
1362 return class->get_backend_property_finish (
1363 client, result, prop_value, error);
1367 * e_client_get_backend_property_sync:
1368 * @client: an #EClient
1369 * @prop_name: property name, whose value to retrieve; cannot be %NULL
1370 * @prop_value: (out): Retrieved backend property value; cannot be %NULL
1371 * @cancellable: a #GCancellable; can be %NULL
1372 * @error: (out): a #GError to set an error, if any
1374 * Queries @client's backend for a property of name @prop_name.
1376 * Returns: %TRUE if successful, %FALSE otherwise.
1381 e_client_get_backend_property_sync (EClient *client,
1382 const gchar *prop_name,
1384 GCancellable *cancellable,
1387 EClientClass *class;
1389 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1390 g_return_val_if_fail (prop_name != NULL, FALSE);
1391 g_return_val_if_fail (prop_value != NULL, FALSE);
1393 class = E_CLIENT_GET_CLASS (client);
1394 g_return_val_if_fail (class != NULL, FALSE);
1395 g_return_val_if_fail (class->get_backend_property_sync != NULL, FALSE);
1397 return class->get_backend_property_sync (
1398 client, prop_name, prop_value, cancellable, error);
1402 * e_client_set_backend_property:
1403 * @client: an #EClient
1404 * @prop_name: property name, whose value to change; cannot be %NULL
1405 * @prop_value: property value, to set; cannot be %NULL
1406 * @cancellable: a #GCancellable; can be %NULL
1407 * @callback: callback to call when a result is ready
1408 * @user_data: user data for the @callback
1410 * Sets @client's backend property of name @prop_name
1411 * to value @prop_value. The call is finished
1412 * by e_client_set_backend_property_finish() from the @callback.
1416 * Deprecated: 3.8: Clients cannot set backend properties. Any attempt
1417 * will fail with an %E_CLIENT_ERROR_NOT_SUPPORTED error.
1420 e_client_set_backend_property (EClient *client,
1421 const gchar *prop_name,
1422 const gchar *prop_value,
1423 GCancellable *cancellable,
1424 GAsyncReadyCallback callback,
1427 EClientClass *class;
1429 g_return_if_fail (callback != NULL);
1430 g_return_if_fail (E_IS_CLIENT (client));
1431 g_return_if_fail (prop_name != NULL);
1432 g_return_if_fail (prop_value != NULL);
1434 class = E_CLIENT_GET_CLASS (client);
1435 g_return_if_fail (class != NULL);
1436 g_return_if_fail (class->set_backend_property != NULL);
1438 class->set_backend_property (client, prop_name, prop_value, cancellable, callback, user_data);
1442 * e_client_set_backend_property_finish:
1443 * @client: an #EClient
1444 * @result: a #GAsyncResult
1445 * @error: (out): a #GError to set an error, if any
1447 * Finishes previous call of e_client_set_backend_property().
1449 * Returns: %TRUE if successful, %FALSE otherwise.
1453 * Deprecated: 3.8: Clients cannot set backend properties. Any attempt
1454 * will fail with an %E_CLIENT_ERROR_NOT_SUPPORTED error.
1457 e_client_set_backend_property_finish (EClient *client,
1458 GAsyncResult *result,
1461 EClientClass *class;
1463 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1465 class = E_CLIENT_GET_CLASS (client);
1466 g_return_val_if_fail (class != NULL, FALSE);
1467 g_return_val_if_fail (class->set_backend_property_finish != NULL, FALSE);
1469 return class->set_backend_property_finish (client, result, error);
1473 * e_client_set_backend_property_sync:
1474 * @client: an #EClient
1475 * @prop_name: property name, whose value to change; cannot be %NULL
1476 * @prop_value: property value, to set; cannot be %NULL
1477 * @cancellable: a #GCancellable; can be %NULL
1478 * @error: (out): a #GError to set an error, if any
1480 * Sets @client's backend property of name @prop_name
1481 * to value @prop_value.
1483 * Returns: %TRUE if successful, %FALSE otherwise.
1487 * Deprecated: 3.8: Clients cannot set backend properties. Any attempt
1488 * will fail with an %E_CLIENT_ERROR_NOT_SUPPORTED error.
1491 e_client_set_backend_property_sync (EClient *client,
1492 const gchar *prop_name,
1493 const gchar *prop_value,
1494 GCancellable *cancellable,
1497 EClientClass *class;
1499 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1500 g_return_val_if_fail (prop_name != NULL, FALSE);
1501 g_return_val_if_fail (prop_value != NULL, FALSE);
1503 class = E_CLIENT_GET_CLASS (client);
1504 g_return_val_if_fail (class != NULL, FALSE);
1505 g_return_val_if_fail (class->set_backend_property_sync != NULL, FALSE);
1507 return class->set_backend_property_sync (
1508 client, prop_name, prop_value, cancellable, error);
1513 * @client: an #EClient
1514 * @only_if_exists: if %TRUE, fail if this book doesn't already exist, otherwise create it first
1515 * @cancellable: a #GCancellable; can be %NULL
1516 * @callback: callback to call when a result is ready
1517 * @user_data: user data for the @callback
1519 * Opens the @client, making it ready for queries and other operations.
1520 * The call is finished by e_client_open_finish() from the @callback.
1524 * Deprecated: 3.8: Use e_book_client_connect() and
1525 * e_book_client_connect_finish() or
1526 * e_cal_client_connect() and
1527 * e_cal_client_connect_finish() instead.
1530 e_client_open (EClient *client,
1531 gboolean only_if_exists,
1532 GCancellable *cancellable,
1533 GAsyncReadyCallback callback,
1536 EClientClass *class;
1538 g_return_if_fail (callback != NULL);
1539 g_return_if_fail (E_IS_CLIENT (client));
1541 class = E_CLIENT_GET_CLASS (client);
1542 g_return_if_fail (class != NULL);
1543 g_return_if_fail (class->open != NULL);
1545 class->open (client, only_if_exists, cancellable, callback, user_data);
1549 * e_client_open_finish:
1550 * @client: an #EClient
1551 * @result: a #GAsyncResult
1552 * @error: (out): a #GError to set an error, if any
1554 * Finishes previous call of e_client_open().
1556 * Returns: %TRUE if successful, %FALSE otherwise.
1560 * Deprecated: 3.8: Use e_book_client_connect() and
1561 * e_book_client_connect_finish() or
1562 * e_cal_client_connect() and
1563 * e_cal_client_connect_finish() instead.
1566 e_client_open_finish (EClient *client,
1567 GAsyncResult *result,
1570 EClientClass *class;
1572 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1574 class = E_CLIENT_GET_CLASS (client);
1575 g_return_val_if_fail (class != NULL, FALSE);
1576 g_return_val_if_fail (class->open_finish != NULL, FALSE);
1578 return class->open_finish (client, result, error);
1582 * e_client_open_sync:
1583 * @client: an #EClient
1584 * @only_if_exists: if %TRUE, fail if this book doesn't already exist, otherwise create it first
1585 * @cancellable: a #GCancellable; can be %NULL
1586 * @error: (out): a #GError to set an error, if any
1588 * Opens the @client, making it ready for queries and other operations.
1590 * Returns: %TRUE if successful, %FALSE otherwise.
1594 * Deprecated: 3.8: Use e_book_client_connect_sync() or
1595 * e_cal_client_connect_sync() instead.
1598 e_client_open_sync (EClient *client,
1599 gboolean only_if_exists,
1600 GCancellable *cancellable,
1603 EClientClass *class;
1605 class = E_CLIENT_GET_CLASS (client);
1606 g_return_val_if_fail (class != NULL, FALSE);
1607 g_return_val_if_fail (class->open_sync != NULL, FALSE);
1609 return class->open_sync (client, only_if_exists, cancellable, error);
1614 * @client: an #EClient
1615 * @cancellable: a #GCancellable; can be %NULL
1616 * @callback: callback to call when a result is ready
1617 * @user_data: user data for the @callback
1619 * Removes the backing data for this #EClient. For example, with the file
1620 * backend this deletes the database file. You cannot get it back!
1621 * The call is finished by e_client_remove_finish() from the @callback.
1625 * Deprecated: 3.6: Use e_source_remove() instead.
1628 e_client_remove (EClient *client,
1629 GCancellable *cancellable,
1630 GAsyncReadyCallback callback,
1633 EClientClass *class;
1635 g_return_if_fail (E_IS_CLIENT (client));
1636 g_return_if_fail (callback != NULL);
1638 class = E_CLIENT_GET_CLASS (client);
1639 g_return_if_fail (class != NULL);
1640 g_return_if_fail (class->remove != NULL);
1642 class->remove (client, cancellable, callback, user_data);
1646 * e_client_remove_finish:
1647 * @client: an #EClient
1648 * @result: a #GAsyncResult
1649 * @error: (out): a #GError to set an error, if any
1651 * Finishes previous call of e_client_remove().
1653 * Returns: %TRUE if successful, %FALSE otherwise.
1657 * Deprecated: 3.6: Use e_source_remove_finish() instead.
1660 e_client_remove_finish (EClient *client,
1661 GAsyncResult *result,
1664 EClientClass *class;
1666 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1668 class = E_CLIENT_GET_CLASS (client);
1669 g_return_val_if_fail (class != NULL, FALSE);
1670 g_return_val_if_fail (class->remove_finish != NULL, FALSE);
1672 return class->remove_finish (client, result, error);
1676 * e_client_remove_sync:
1677 * @client: an #EClient
1678 * @cancellable: a #GCancellable; can be %NULL
1679 * @error: (out): a #GError to set an error, if any
1681 * Removes the backing data for this #EClient. For example, with the file
1682 * backend this deletes the database file. You cannot get it back!
1684 * Returns: %TRUE if successful, %FALSE otherwise.
1688 * Deprecated: 3.6: Use e_source_remove_sync() instead.
1691 e_client_remove_sync (EClient *client,
1692 GCancellable *cancellable,
1695 EClientClass *class;
1697 class = E_CLIENT_GET_CLASS (client);
1698 g_return_val_if_fail (class != NULL, FALSE);
1699 g_return_val_if_fail (class->remove_sync != NULL, FALSE);
1701 return class->remove_sync (client, cancellable, error);
1706 * @client: an #EClient
1707 * @cancellable: a #GCancellable; can be %NULL
1708 * @callback: callback to call when a result is ready
1709 * @user_data: user data for the @callback
1711 * Initiates refresh on the @client. Finishing the method doesn't mean
1712 * that the refresh is done, backend only notifies whether it started
1713 * refreshing or not. Use e_client_check_refresh_supported() to check
1714 * whether the backend supports this method.
1715 * The call is finished by e_client_refresh_finish() from the @callback.
1720 e_client_refresh (EClient *client,
1721 GCancellable *cancellable,
1722 GAsyncReadyCallback callback,
1725 EClientClass *class;
1727 g_return_if_fail (E_IS_CLIENT (client));
1728 g_return_if_fail (callback != NULL);
1730 class = E_CLIENT_GET_CLASS (client);
1731 g_return_if_fail (class != NULL);
1732 g_return_if_fail (class->refresh != NULL);
1734 class->refresh (client, cancellable, callback, user_data);
1738 * e_client_refresh_finish:
1739 * @client: an #EClient
1740 * @result: a #GAsyncResult
1741 * @error: (out): a #GError to set an error, if any
1743 * Finishes previous call of e_client_refresh().
1745 * Returns: %TRUE if successful, %FALSE otherwise.
1750 e_client_refresh_finish (EClient *client,
1751 GAsyncResult *result,
1754 EClientClass *class;
1756 g_return_val_if_fail (E_IS_CLIENT (client), FALSE);
1758 class = E_CLIENT_GET_CLASS (client);
1759 g_return_val_if_fail (class != NULL, FALSE);
1760 g_return_val_if_fail (class->refresh_finish != NULL, FALSE);
1762 return class->refresh_finish (client, result, error);
1766 * e_client_refresh_sync:
1767 * @client: an #EClient
1768 * @cancellable: a #GCancellable; can be %NULL
1769 * @error: (out): a #GError to set an error, if any
1771 * Initiates refresh on the @client. Finishing the method doesn't mean
1772 * that the refresh is done, backend only notifies whether it started
1773 * refreshing or not. Use e_client_check_refresh_supported() to check
1774 * whether the backend supports this method.
1776 * Returns: %TRUE if successful, %FALSE otherwise.
1781 e_client_refresh_sync (EClient *client,
1782 GCancellable *cancellable,
1785 EClientClass *class;
1787 class = E_CLIENT_GET_CLASS (client);
1788 g_return_val_if_fail (class != NULL, FALSE);
1789 g_return_val_if_fail (class->refresh_sync != NULL, FALSE);
1791 return class->refresh_sync (client, cancellable, error);
1795 * e_client_util_slist_to_strv:
1796 * @strings: (element-type utf8): a #GSList of strings (const gchar *)
1798 * Convert a list of strings into a %NULL-terminated array of strings.
1800 * Returns: (transfer full): Newly allocated %NULL-terminated array of strings.
1801 * The returned pointer should be freed with g_strfreev().
1803 * Note: Paired function for this is e_client_util_strv_to_slist().
1807 * Deprecated: 3.8: Use e_util_slist_to_strv() instead.
1810 e_client_util_slist_to_strv (const GSList *strings)
1812 return e_util_slist_to_strv (strings);
1816 * e_client_util_strv_to_slist:
1817 * @strv: a %NULL-terminated array of strings (const gchar *)
1819 * Convert a %NULL-terminated array of strings to a list of strings.
1821 * Returns: (transfer full) (element-type utf8): Newly allocated #GSList of
1822 * newly allocated strings. The returned pointer should be freed with
1823 * e_client_util_free_string_slist().
1825 * Note: Paired function for this is e_client_util_slist_to_strv().
1829 * Deprecated: 3.8: Use e_util_strv_to_slist() instead.
1832 e_client_util_strv_to_slist (const gchar * const *strv)
1834 return e_util_strv_to_slist (strv);
1838 * e_client_util_copy_string_slist:
1839 * @copy_to: (element-type utf8) (allow-none): Where to copy; may be %NULL
1840 * @strings: (element-type utf8): #GSList of strings to be copied
1842 * Copies the #GSList of strings to the end of @copy_to.
1844 * Returns: (transfer full) (element-type utf8): New head of @copy_to.
1845 * The returned pointer can be freed with e_client_util_free_string_slist().
1849 * Deprecated: 3.8: Use e_util_copy_string_slist() instead.
1852 e_client_util_copy_string_slist (GSList *copy_to,
1853 const GSList *strings)
1855 return e_util_copy_string_slist (copy_to, strings);
1859 * e_client_util_copy_object_slist:
1860 * @copy_to: (element-type GObject) (allow-none): Where to copy; may be %NULL
1861 * @objects: (element-type GObject): #GSList of #GObject<!-- -->s to be copied
1863 * Copies a #GSList of #GObject<!-- -->s to the end of @copy_to.
1865 * Returns: (transfer full) (element-type GObject): New head of @copy_to.
1866 * The returned pointer can be freed with e_client_util_free_object_slist().
1870 * Deprecated: 3.8: Use e_util_copy_object_slist() instead.
1873 e_client_util_copy_object_slist (GSList *copy_to,
1874 const GSList *objects)
1876 return e_util_copy_object_slist (copy_to, objects);
1880 * e_client_util_free_string_slist:
1881 * @strings: (element-type utf8): a #GSList of strings (gchar *)
1883 * Frees memory previously allocated by e_client_util_strv_to_slist().
1887 * Deprecated: 3.8: Use g_slist_free_full() instead.
1890 e_client_util_free_string_slist (GSList *strings)
1892 e_util_free_string_slist (strings);
1896 * e_client_util_free_object_slist:
1897 * @objects: (element-type GObject): a #GSList of #GObject<!-- -->s
1899 * Calls g_object_unref() on each member of @objects and then frees @objects
1904 * Deprecated: 3.8: Use g_slist_free_full() instead.
1907 e_client_util_free_object_slist (GSList *objects)
1909 e_util_free_object_slist (objects);
1913 * e_client_util_parse_comma_strings:
1914 * @strings: string of comma-separated values
1916 * Parses comma-separated list of values into #GSList.
1918 * Returns: (transfer full) (element-type utf8): Newly allocated #GSList of
1919 * newly allocated strings corresponding to values parsed from @strings.
1920 * Free the returned pointer with e_client_util_free_string_slist().
1925 e_client_util_parse_comma_strings (const gchar *strings)
1927 GSList *strs_slist = NULL;
1928 gchar **strs_strv = NULL;
1931 if (!strings || !*strings)
1934 strs_strv = g_strsplit (strings, ",", -1);
1935 g_return_val_if_fail (strs_strv != NULL, NULL);
1937 for (ii = 0; strs_strv && strs_strv[ii]; ii++) {
1938 gchar *str = g_strstrip (strs_strv[ii]);
1941 strs_slist = g_slist_prepend (strs_slist, g_strdup (str));
1944 g_strfreev (strs_strv);
1946 return g_slist_reverse (strs_slist);
1950 * e_client_unwrap_dbus_error:
1951 * @client: an #EClient
1952 * @dbus_error: a #GError returned bu D-Bus
1953 * @out_error: a #GError variable where to store the result
1955 * Unwraps D-Bus error to local error. @dbus_error is automatically freed.
1956 * @dbus_erorr and @out_error can point to the same variable.
1960 * Deprecated: 3.8: Use g_dbus_error_strip_remote_error() instead.
1963 e_client_unwrap_dbus_error (EClient *client,
1967 EClientClass *class;
1969 g_return_if_fail (E_IS_CLIENT (client));
1971 class = E_CLIENT_GET_CLASS (client);
1972 g_return_if_fail (class != NULL);
1973 g_return_if_fail (class->unwrap_dbus_error != NULL);
1975 if (!dbus_error || !out_error) {
1977 g_error_free (dbus_error);
1979 class->unwrap_dbus_error (client, dbus_error, out_error);
1984 * e_client_util_unwrap_dbus_error:
1985 * @dbus_error: DBus #GError to unwrap
1986 * @client_error: (out): Resulting #GError; can be %NULL
1987 * @known_errors: List of known errors against which try to match
1988 * @known_errors_count: How many items are stored in @known_errors
1989 * @known_errors_domain: Error domain for @known_errors
1990 * @fail_when_none_matched: Whether to fail when none of @known_errors matches
1992 * The function takes a @dbus_error and tries to find a match in @known_errors
1993 * for it, if it is a G_IO_ERROR, G_IO_ERROR_DBUS_ERROR. If it is anything else
1994 * then the @dbus_error is moved to @client_error.
1996 * The @fail_when_none_matched influences behaviour. If it's %TRUE, and none of
1997 * @known_errors matches, or this is not a G_IO_ERROR_DBUS_ERROR, then %FALSE
1998 * is returned and the @client_error is left without change. Otherwise, the
1999 * @fail_when_none_matched is %FALSE, the error is always processed and will
2000 * result in E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR if none of @known_error
2003 * Returns: Whether was @dbus_error processed into @client_error.
2005 * Note: The @dbus_error is automatically freed if returned %TRUE.
2009 * Deprecated: 3.8: This function is no longer used.
2012 e_client_util_unwrap_dbus_error (GError *dbus_error,
2013 GError **client_error,
2014 const EClientErrorsList *known_errors,
2015 guint known_errors_count,
2016 GQuark known_errors_domain,
2017 gboolean fail_when_none_matched)
2019 if (!client_error) {
2021 g_error_free (dbus_error);
2026 *client_error = NULL;
2030 if (dbus_error->domain == known_errors_domain) {
2031 *client_error = dbus_error;
2036 if (g_error_matches (dbus_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR)) {
2040 name = g_dbus_error_get_remote_error (dbus_error);
2042 for (ii = 0; ii < known_errors_count; ii++) {
2043 if (g_ascii_strcasecmp (known_errors[ii].name, name) == 0) {
2046 g_dbus_error_strip_remote_error (dbus_error);
2047 *client_error = g_error_new_literal (known_errors_domain, known_errors[ii].err_code, dbus_error->message);
2048 g_error_free (dbus_error);
2057 if (fail_when_none_matched)
2060 if (g_error_matches (dbus_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR)) {
2061 g_dbus_error_strip_remote_error (dbus_error);
2062 *client_error = g_error_new_literal (E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR, dbus_error->message);
2063 g_error_free (dbus_error);
2065 g_dbus_error_strip_remote_error (dbus_error);
2066 *client_error = dbus_error;