"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/calendar/libedata-cal/e-cal-backend.c" between
evolution-data-server-3.32.4.tar.xz and evolution-data-server-3.34.0.tar.xz

About: Evolution-Data-Server manages access to the calendar, tasks and addressbook information available for Evolution and other applications.

e-cal-backend.c  (evolution-data-server-3.32.4.tar.xz):e-cal-backend.c  (evolution-data-server-3.34.0.tar.xz)
skipping to change at line 32 skipping to change at line 32
* *
* This is the main server facing API for interfacing with calendar backends, * This is the main server facing API for interfacing with calendar backends,
* calendar backends must implement methods on this class. * calendar backends must implement methods on this class.
**/ **/
#include "evolution-data-server-config.h" #include "evolution-data-server-config.h"
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include "e-cal-backend.h" #include "e-cal-backend.h"
#include "e-cal-backend-cache.h"
#define E_CAL_BACKEND_GET_PRIVATE(obj) \ #define E_CAL_BACKEND_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \ (G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_CAL_BACKEND, ECalBackendPrivate)) ((obj), E_TYPE_CAL_BACKEND, ECalBackendPrivate))
typedef struct _AsyncContext AsyncContext; typedef struct _AsyncContext AsyncContext;
typedef struct _DispatchNode DispatchNode; typedef struct _DispatchNode DispatchNode;
typedef struct _SignalClosure SignalClosure; typedef struct _SignalClosure SignalClosure;
struct _ECalBackendPrivate { struct _ECalBackendPrivate {
ESourceRegistry *registry; ESourceRegistry *registry;
EDataCal *data_cal; EDataCal *data_cal;
gboolean opened; gboolean opened;
/* The kind of components for this backend */ /* The kind of components for this backend */
icalcomponent_kind kind; ICalComponentKind kind;
GMutex views_mutex; GMutex views_mutex;
GList *views; GList *views;
GMutex property_lock; GMutex property_lock;
GProxyResolver *proxy_resolver; GProxyResolver *proxy_resolver;
gchar *cache_dir; gchar *cache_dir;
gboolean writable; gboolean writable;
ESource *authentication_source; ESource *authentication_source;
skipping to change at line 88 skipping to change at line 87
gchar *alarm_uid; gchar *alarm_uid;
gchar *calobj; gchar *calobj;
gchar *query; gchar *query;
gchar *tzid; gchar *tzid;
gchar *tzobject; gchar *tzobject;
ECalObjModType mod; ECalObjModType mod;
time_t start; time_t start;
time_t end; time_t end;
GSList *compid_list; GSList *compid_list;
GSList *string_list; GSList *string_list;
guint32 opflags;
/* Outputs */ /* Outputs */
GQueue result_queue; GQueue result_queue;
/* One of these should point to result_queue /* One of these should point to result_queue
* so any leftover resources can be released. */ * so any leftover resources can be released. */
GQueue *object_queue; GQueue *object_queue;
GQueue *string_queue; GQueue *string_queue;
}; };
skipping to change at line 115 skipping to change at line 115
GCancellable *cancellable; GCancellable *cancellable;
GWeakRef *cal_backend_weak_ref; GWeakRef *cal_backend_weak_ref;
ECalBackendCustomOpFunc custom_func; ECalBackendCustomOpFunc custom_func;
gpointer custom_func_user_data; gpointer custom_func_user_data;
GDestroyNotify custom_func_user_data_free; GDestroyNotify custom_func_user_data_free;
}; };
struct _SignalClosure { struct _SignalClosure {
GWeakRef backend; GWeakRef backend;
icaltimezone *cached_zone; ICalTimezone *cached_zone;
}; };
enum { enum {
PROP_0, PROP_0,
PROP_CACHE_DIR, PROP_CACHE_DIR,
PROP_KIND, PROP_KIND,
PROP_PROXY_RESOLVER, PROP_PROXY_RESOLVER,
PROP_REGISTRY, PROP_REGISTRY,
PROP_WRITABLE PROP_WRITABLE
}; };
skipping to change at line 162 skipping to change at line 162
g_free (async_context->uid); g_free (async_context->uid);
g_free (async_context->rid); g_free (async_context->rid);
g_free (async_context->alarm_uid); g_free (async_context->alarm_uid);
g_free (async_context->calobj); g_free (async_context->calobj);
g_free (async_context->query); g_free (async_context->query);
g_free (async_context->tzid); g_free (async_context->tzid);
g_free (async_context->tzobject); g_free (async_context->tzobject);
g_slist_free_full ( g_slist_free_full (
async_context->compid_list, async_context->compid_list,
(GDestroyNotify) e_cal_component_free_id); (GDestroyNotify) e_cal_component_id_free);
g_slist_free_full ( g_slist_free_full (
async_context->string_list, async_context->string_list,
(GDestroyNotify) g_free); (GDestroyNotify) g_free);
queue = async_context->object_queue; queue = async_context->object_queue;
while (queue != NULL && !g_queue_is_empty (queue)) while (queue != NULL && !g_queue_is_empty (queue))
g_object_unref (g_queue_pop_head (queue)); g_object_unref (g_queue_pop_head (queue));
queue = async_context->string_queue; queue = async_context->string_queue;
skipping to change at line 198 skipping to change at line 198
if (dispatch_node->cal_backend_weak_ref) if (dispatch_node->cal_backend_weak_ref)
e_weak_ref_free (dispatch_node->cal_backend_weak_ref); e_weak_ref_free (dispatch_node->cal_backend_weak_ref);
g_slice_free (DispatchNode, dispatch_node); g_slice_free (DispatchNode, dispatch_node);
} }
static void static void
signal_closure_free (SignalClosure *signal_closure) signal_closure_free (SignalClosure *signal_closure)
{ {
g_weak_ref_clear (&signal_closure->backend); g_weak_ref_clear (&signal_closure->backend);
g_clear_object (&signal_closure->cached_zone);
/* The icaltimezone is cached in ECalBackend's internal
* "zone_cache" hash table and must not be freed here. */
g_slice_free (SignalClosure, signal_closure); g_slice_free (SignalClosure, signal_closure);
} }
static void static void
cal_backend_free_zone (icaltimezone *zone)
{
icaltimezone_free (zone, 1);
}
static void
cal_backend_push_operation (ECalBackend *backend, cal_backend_push_operation (ECalBackend *backend,
GSimpleAsyncResult *simple, GSimpleAsyncResult *simple,
GCancellable *cancellable, GCancellable *cancellable,
gboolean blocking_operation, gboolean blocking_operation,
GSimpleAsyncThreadFunc dispatch_func) GSimpleAsyncThreadFunc dispatch_func)
{ {
DispatchNode *node; DispatchNode *node;
g_return_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple)); g_return_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple));
g_return_if_fail (dispatch_func != NULL); g_return_if_fail (dispatch_func != NULL);
skipping to change at line 393 skipping to change at line 385
g_mutex_unlock (&backend->priv->operation_lock); g_mutex_unlock (&backend->priv->operation_lock);
return simple; return simple;
} }
static void static void
cal_backend_set_default_cache_dir (ECalBackend *backend) cal_backend_set_default_cache_dir (ECalBackend *backend)
{ {
ESource *source; ESource *source;
icalcomponent_kind kind; ICalComponentKind kind;
const gchar *component_type; const gchar *component_type;
const gchar *user_cache_dir; const gchar *user_cache_dir;
const gchar *uid; const gchar *uid;
gchar *filename; gchar *filename;
user_cache_dir = e_get_user_cache_dir (); user_cache_dir = e_get_user_cache_dir ();
kind = e_cal_backend_get_kind (backend); kind = e_cal_backend_get_kind (backend);
source = e_backend_get_source (E_BACKEND (backend)); source = e_backend_get_source (E_BACKEND (backend));
uid = e_source_get_uid (source); uid = e_source_get_uid (source);
g_return_if_fail (uid != NULL); g_return_if_fail (uid != NULL);
switch (kind) { switch (kind) {
case ICAL_VEVENT_COMPONENT: case I_CAL_VEVENT_COMPONENT:
component_type = "calendar"; component_type = "calendar";
break; break;
case ICAL_VTODO_COMPONENT: case I_CAL_VTODO_COMPONENT:
component_type = "tasks"; component_type = "tasks";
break; break;
case ICAL_VJOURNAL_COMPONENT: case I_CAL_VJOURNAL_COMPONENT:
component_type = "memos"; component_type = "memos";
break; break;
default: default:
g_return_if_reached (); g_return_if_reached ();
} }
filename = g_build_filename ( filename = g_build_filename (
user_cache_dir, component_type, uid, NULL); user_cache_dir, component_type, uid, NULL);
e_cal_backend_set_cache_dir (backend, filename); e_cal_backend_set_cache_dir (backend, filename);
g_free (filename); g_free (filename);
skipping to change at line 550 skipping to change at line 542
backend, "timezone-added", backend, "timezone-added",
signal_closure->cached_zone); signal_closure->cached_zone);
g_object_unref (backend); g_object_unref (backend);
} }
return FALSE; return FALSE;
} }
static void static void
cal_backend_set_kind (ECalBackend *backend, cal_backend_set_kind (ECalBackend *backend,
icalcomponent_kind kind) ICalComponentKind kind)
{ {
backend->priv->kind = kind; backend->priv->kind = kind;
} }
static void static void
cal_backend_set_registry (ECalBackend *backend, cal_backend_set_registry (ECalBackend *backend,
ESourceRegistry *registry) ESourceRegistry *registry)
{ {
g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
g_return_if_fail (backend->priv->registry == NULL); g_return_if_fail (backend->priv->registry == NULL);
skipping to change at line 660 skipping to change at line 652
priv->authentication_source, priv->authentication_source,
priv->auth_source_changed_handler_id); priv->auth_source_changed_handler_id);
priv->auth_source_changed_handler_id = 0; priv->auth_source_changed_handler_id = 0;
} }
g_clear_object (&priv->registry); g_clear_object (&priv->registry);
g_clear_object (&priv->data_cal); g_clear_object (&priv->data_cal);
g_clear_object (&priv->proxy_resolver); g_clear_object (&priv->proxy_resolver);
g_clear_object (&priv->authentication_source); g_clear_object (&priv->authentication_source);
g_mutex_lock (&priv->views_mutex);
g_list_free_full (priv->views, g_object_unref);
priv->views = NULL;
g_mutex_unlock (&priv->views_mutex);
g_hash_table_remove_all (priv->operation_ids); g_hash_table_remove_all (priv->operation_ids);
while (!g_queue_is_empty (&priv->pending_operations)) while (!g_queue_is_empty (&priv->pending_operations))
g_object_unref (g_queue_pop_head (&priv->pending_operations)); g_object_unref (g_queue_pop_head (&priv->pending_operations));
g_clear_object (&priv->blocked); g_clear_object (&priv->blocked);
/* Chain up to parent's dispose() method. */ /* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_cal_backend_parent_class)->dispose (object); G_OBJECT_CLASS (e_cal_backend_parent_class)->dispose (object);
} }
static void static void
cal_backend_finalize (GObject *object) cal_backend_finalize (GObject *object)
{ {
ECalBackendPrivate *priv; ECalBackendPrivate *priv;
priv = E_CAL_BACKEND_GET_PRIVATE (object); priv = E_CAL_BACKEND_GET_PRIVATE (object);
g_list_free (priv->views);
g_mutex_clear (&priv->views_mutex); g_mutex_clear (&priv->views_mutex);
g_mutex_clear (&priv->property_lock); g_mutex_clear (&priv->property_lock);
g_free (priv->cache_dir); g_free (priv->cache_dir);
g_hash_table_destroy (priv->zone_cache); g_hash_table_destroy (priv->zone_cache);
g_mutex_clear (&priv->zone_cache_lock); g_mutex_clear (&priv->zone_cache_lock);
g_mutex_clear (&priv->operation_lock); g_mutex_clear (&priv->operation_lock);
g_hash_table_destroy (priv->operation_ids); g_hash_table_destroy (priv->operation_ids);
skipping to change at line 800 skipping to change at line 796
{ {
g_return_if_fail (E_IS_CAL_BACKEND (cal_backend)); g_return_if_fail (E_IS_CAL_BACKEND (cal_backend));
g_mutex_lock (&cal_backend->priv->zone_cache_lock); g_mutex_lock (&cal_backend->priv->zone_cache_lock);
g_hash_table_remove_all (cal_backend->priv->zone_cache); g_hash_table_remove_all (cal_backend->priv->zone_cache);
g_mutex_unlock (&cal_backend->priv->zone_cache_lock); g_mutex_unlock (&cal_backend->priv->zone_cache_lock);
} }
static void static void
cal_backend_add_cached_timezone (ETimezoneCache *cache, cal_backend_add_cached_timezone (ETimezoneCache *cache,
icaltimezone *zone) ICalTimezone *zone)
{ {
ECalBackendPrivate *priv; ECalBackendPrivate *priv;
const gchar *tzid; const gchar *tzid;
priv = E_CAL_BACKEND_GET_PRIVATE (cache); priv = E_CAL_BACKEND_GET_PRIVATE (cache);
/* XXX Apparently this function can sometimes return NULL. /* XXX Apparently this function can sometimes return NULL.
* I'm not sure when or why that happens, but we can't * I'm not sure when or why that happens, but we can't
* cache the icaltimezone if it has no tzid string. */ * cache the ICalTimezone if it has no tzid string. */
tzid = icaltimezone_get_tzid (zone); tzid = i_cal_timezone_get_tzid (zone);
if (tzid == NULL) if (tzid == NULL)
return; return;
g_mutex_lock (&priv->zone_cache_lock); g_mutex_lock (&priv->zone_cache_lock);
/* Avoid replacing an existing cache entry. We don't want to /* Avoid replacing an existing cache entry. We don't want to
* invalidate any icaltimezone pointers that may have already * invalidate any ICalTimezone pointers that may have already
* been returned through e_timezone_cache_get_timezone(). */ * been returned through e_timezone_cache_get_timezone(). */
if (!g_hash_table_contains (priv->zone_cache, tzid)) { if (!g_hash_table_contains (priv->zone_cache, tzid)) {
GSource *idle_source; GSource *idle_source;
GMainContext *main_context; GMainContext *main_context;
SignalClosure *signal_closure; SignalClosure *signal_closure;
icalcomponent *icalcomp; ICalTimezone *cached_zone;
icaltimezone *cached_zone;
cached_zone = icaltimezone_new (); cached_zone = e_cal_util_copy_timezone (zone);
icalcomp = icaltimezone_get_component (zone);
icalcomp = icalcomponent_new_clone (icalcomp);
icaltimezone_set_component (cached_zone, icalcomp);
g_hash_table_insert ( g_hash_table_insert (
priv->zone_cache, priv->zone_cache,
g_strdup (tzid), cached_zone); g_strdup (tzid), cached_zone);
/* The closure's backend reference will keep the /* The closure's backend reference will keep the
* internally cached icaltimezone alive for the * internally cached ICalTimezone alive for the
* duration of the idle callback. */ * duration of the idle callback. */
signal_closure = g_slice_new0 (SignalClosure); signal_closure = g_slice_new0 (SignalClosure);
g_weak_ref_init (&signal_closure->backend, cache); g_weak_ref_init (&signal_closure->backend, cache);
signal_closure->cached_zone = cached_zone; signal_closure->cached_zone = g_object_ref (cached_zone);
main_context = e_backend_ref_main_context (E_BACKEND (cache)); main_context = e_backend_ref_main_context (E_BACKEND (cache));
idle_source = g_idle_source_new (); idle_source = g_idle_source_new ();
g_source_set_callback ( g_source_set_callback (
idle_source, idle_source,
cal_backend_emit_timezone_added_idle_cb, cal_backend_emit_timezone_added_idle_cb,
signal_closure, signal_closure,
(GDestroyNotify) signal_closure_free); (GDestroyNotify) signal_closure_free);
g_source_attach (idle_source, main_context); g_source_attach (idle_source, main_context);
g_source_unref (idle_source); g_source_unref (idle_source);
g_main_context_unref (main_context); g_main_context_unref (main_context);
} }
g_mutex_unlock (&priv->zone_cache_lock); g_mutex_unlock (&priv->zone_cache_lock);
} }
static icaltimezone * static ICalTimezone *
cal_backend_get_cached_timezone (ETimezoneCache *cache, cal_backend_get_cached_timezone (ETimezoneCache *cache,
const gchar *tzid) const gchar *tzid)
{ {
ECalBackendPrivate *priv; ECalBackendPrivate *priv;
icaltimezone *zone = NULL; ICalTimezone *zone = NULL;
icaltimezone *builtin_zone = NULL; ICalTimezone *builtin_zone = NULL;
icalcomponent *icalcomp; ICalComponent *icomp, *clone;
icalproperty *prop; ICalProperty *prop;
const gchar *builtin_tzid; const gchar *builtin_tzid;
priv = E_CAL_BACKEND_GET_PRIVATE (cache); priv = E_CAL_BACKEND_GET_PRIVATE (cache);
if (g_str_equal (tzid, "UTC")) if (g_str_equal (tzid, "UTC"))
return icaltimezone_get_utc_timezone (); return i_cal_timezone_get_utc_timezone ();
g_mutex_lock (&priv->zone_cache_lock); g_mutex_lock (&priv->zone_cache_lock);
/* See if we already have it in the cache. */ /* See if we already have it in the cache. */
zone = g_hash_table_lookup (priv->zone_cache, tzid); zone = g_hash_table_lookup (priv->zone_cache, tzid);
if (zone != NULL) if (zone != NULL)
goto exit; goto exit;
/* Try to replace the original time zone with a more complete /* Try to replace the original time zone with a more complete
* and/or potentially updated built-in time zone. Note this also * and/or potentially updated built-in time zone. Note this also
* applies to TZIDs which match built-in time zones exactly: they * applies to TZIDs which match built-in time zones exactly: they
* are extracted via icaltimezone_get_builtin_timezone_from_tzid(). */ * are extracted via i_cal_timezone_get_builtin_timezone_from_tzid(). */
builtin_tzid = e_cal_match_tzid (tzid); builtin_tzid = e_cal_match_tzid (tzid);
if (builtin_tzid != NULL) if (builtin_tzid != NULL)
builtin_zone = icaltimezone_get_builtin_timezone_from_tzid ( builtin_zone = i_cal_timezone_get_builtin_timezone_from_tzid (bui
builtin_tzid); ltin_tzid);
if (builtin_zone == NULL) if (builtin_zone == NULL)
goto exit; goto exit;
/* Use the built-in time zone *and* rename it. Likely the caller /* Use the built-in time zone *and* rename it. Likely the caller
* is asking for a specific TZID because it has an event with such * is asking for a specific TZID because it has an event with such
* a TZID. Returning an icaltimezone with a different TZID would * a TZID. Returning an ICalTimezone with a different TZID would
* lead to broken VCALENDARs in the caller. */ * lead to broken VCALENDARs in the caller. */
icalcomp = icaltimezone_get_component (builtin_zone); icomp = i_cal_timezone_get_component (builtin_zone);
icalcomp = icalcomponent_new_clone (icalcomp); clone = i_cal_component_clone (icomp);
g_object_unref (icomp);
prop = icalcomponent_get_first_property ( icomp = clone;
icalcomp, ICAL_ANY_PROPERTY);
for (prop = i_cal_component_get_first_property (icomp, I_CAL_ANY_PROPERTY
while (prop != NULL) { );
if (icalproperty_isa (prop) == ICAL_TZID_PROPERTY) { prop;
icalproperty_set_value_from_string (prop, tzid, "NO"); g_object_unref (prop), prop = i_cal_component_get_next_property (ico
mp, I_CAL_ANY_PROPERTY)) {
if (i_cal_property_isa (prop) == I_CAL_TZID_PROPERTY) {
i_cal_property_set_value_from_string (prop, tzid, "NO");
g_object_unref (prop);
break; break;
} }
prop = icalcomponent_get_next_property (
icalcomp, ICAL_ANY_PROPERTY);
} }
if (icalcomp != NULL) { zone = i_cal_timezone_new ();
zone = icaltimezone_new (); if (i_cal_timezone_set_component (zone, icomp)) {
if (icaltimezone_set_component (zone, icalcomp)) { tzid = i_cal_timezone_get_tzid (zone);
tzid = icaltimezone_get_tzid (zone); g_hash_table_insert (priv->zone_cache, g_strdup (tzid), zone);
g_hash_table_insert ( } else {
priv->zone_cache, g_clear_object (&zone);
g_strdup (tzid), zone);
} else {
icalcomponent_free (icalcomp);
icaltimezone_free (zone, 1);
zone = NULL;
}
} }
g_clear_object (&icomp);
exit: exit:
g_mutex_unlock (&priv->zone_cache_lock); g_mutex_unlock (&priv->zone_cache_lock);
return zone; return zone;
} }
static GList * static GList *
cal_backend_list_cached_timezones (ETimezoneCache *cache) cal_backend_list_cached_timezones (ETimezoneCache *cache)
{ {
ECalBackendPrivate *priv; ECalBackendPrivate *priv;
GList *list; GList *list;
skipping to change at line 974 skipping to change at line 959
object_class->set_property = cal_backend_set_property; object_class->set_property = cal_backend_set_property;
object_class->get_property = cal_backend_get_property; object_class->get_property = cal_backend_get_property;
object_class->dispose = cal_backend_dispose; object_class->dispose = cal_backend_dispose;
object_class->finalize = cal_backend_finalize; object_class->finalize = cal_backend_finalize;
object_class->constructed = cal_backend_constructed; object_class->constructed = cal_backend_constructed;
backend_class = E_BACKEND_CLASS (class); backend_class = E_BACKEND_CLASS (class);
backend_class->prepare_shutdown = cal_backend_prepare_shutdown; backend_class->prepare_shutdown = cal_backend_prepare_shutdown;
class->use_serial_dispatch_queue = TRUE; class->use_serial_dispatch_queue = TRUE;
class->get_backend_property = cal_backend_get_backend_property; class->impl_get_backend_property = cal_backend_get_backend_property;
class->shutdown = cal_backend_shutdown; class->shutdown = cal_backend_shutdown;
g_object_class_install_property ( g_object_class_install_property (
object_class, object_class,
PROP_CACHE_DIR, PROP_CACHE_DIR,
g_param_spec_string ( g_param_spec_string (
"cache-dir", "cache-dir",
"Cache Dir", "Cache Dir",
"The backend's cache directory", "The backend's cache directory",
NULL, NULL,
skipping to change at line 997 skipping to change at line 982
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
g_object_class_install_property ( g_object_class_install_property (
object_class, object_class,
PROP_KIND, PROP_KIND,
g_param_spec_ulong ( g_param_spec_ulong (
"kind", "kind",
"Kind", "Kind",
"The kind of iCalendar components " "The kind of iCalendar components "
"this backend manages", "this backend manages",
ICAL_NO_COMPONENT, I_CAL_NO_COMPONENT,
ICAL_XLICMIMEPART_COMPONENT, I_CAL_XLICMIMEPART_COMPONENT,
ICAL_NO_COMPONENT, I_CAL_NO_COMPONENT,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
g_object_class_install_property ( g_object_class_install_property (
object_class, object_class,
PROP_PROXY_RESOLVER, PROP_PROXY_RESOLVER,
g_param_spec_object ( g_param_spec_object (
"proxy-resolver", "proxy-resolver",
"Proxy Resolver", "Proxy Resolver",
skipping to change at line 1079 skipping to change at line 1064
G_OBJECT_CLASS_TYPE (object_class), G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ECalBackendClass, shutdown), G_STRUCT_OFFSET (ECalBackendClass, shutdown),
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
} }
static void static void
e_cal_backend_timezone_cache_init (ETimezoneCacheInterface *iface) e_cal_backend_timezone_cache_init (ETimezoneCacheInterface *iface)
{ {
iface->add_timezone = cal_backend_add_cached_timezone; iface->tzcache_add_timezone = cal_backend_add_cached_timezone;
iface->get_timezone = cal_backend_get_cached_timezone; iface->tzcache_get_timezone = cal_backend_get_cached_timezone;
iface->list_timezones = cal_backend_list_cached_timezones; iface->tzcache_list_timezones = cal_backend_list_cached_timezones;
} }
static void static void
e_cal_backend_init (ECalBackend *backend) e_cal_backend_init (ECalBackend *backend)
{ {
GHashTable *zone_cache; GHashTable *zone_cache;
zone_cache = g_hash_table_new_full ( zone_cache = g_hash_table_new_full (
(GHashFunc) g_str_hash, (GHashFunc) g_str_hash,
(GEqualFunc) g_str_equal, (GEqualFunc) g_str_equal,
(GDestroyNotify) g_free, (GDestroyNotify) g_free,
(GDestroyNotify) cal_backend_free_zone); (GDestroyNotify) g_object_unref);
backend->priv = E_CAL_BACKEND_GET_PRIVATE (backend); backend->priv = E_CAL_BACKEND_GET_PRIVATE (backend);
g_mutex_init (&backend->priv->views_mutex); g_mutex_init (&backend->priv->views_mutex);
g_mutex_init (&backend->priv->property_lock); g_mutex_init (&backend->priv->property_lock);
backend->priv->zone_cache = zone_cache; backend->priv->zone_cache = zone_cache;
g_mutex_init (&backend->priv->zone_cache_lock); g_mutex_init (&backend->priv->zone_cache_lock);
g_mutex_init (&backend->priv->operation_lock); g_mutex_init (&backend->priv->operation_lock);
skipping to change at line 1120 skipping to change at line 1105
} }
/** /**
* e_cal_backend_get_kind: * e_cal_backend_get_kind:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* *
* Gets the kind of components the given backend stores. * Gets the kind of components the given backend stores.
* *
* Returns: The kind of components for this backend. * Returns: The kind of components for this backend.
*/ */
icalcomponent_kind ICalComponentKind
e_cal_backend_get_kind (ECalBackend *backend) e_cal_backend_get_kind (ECalBackend *backend)
{ {
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), ICAL_NO_COMPONENT); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), I_CAL_NO_COMPONENT);
return backend->priv->kind; return backend->priv->kind;
} }
/** /**
* e_cal_backend_ref_data_cal: * e_cal_backend_ref_data_cal:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* *
* Returns the #EDataCal for @backend. The #EDataCal is essentially * Returns the #EDataCal for @backend. The #EDataCal is essentially
* the glue between incoming D-Bus requests and @backend's native API. * the glue between incoming D-Bus requests and @backend's native API.
* *
* An #EDataCal should be set only once after @backend is first created. * An #EDataCal should be set only once after @backend is first created.
* If an #EDataCal has not yet been set, the function returns %NULL. * If an #EDataCal has not yet been set, the function returns %NULL.
* *
* The returned #EDataCal is referenced for thread-safety and must be * The returned #EDataCal is referenced for thread-safety and must be
* unreferenced with g_object_unref() when finished with it. * unreferenced with g_object_unref() when finished with it.
* *
* Returns: an #EDataCal, or %NULL * Returns: (transfer full): an #EDataCal, or %NULL
* *
* Since: 3.10 * Since: 3.10
**/ **/
EDataCal * EDataCal *
e_cal_backend_ref_data_cal (ECalBackend *backend) e_cal_backend_ref_data_cal (ECalBackend *backend)
{ {
EDataCal *data_cal = NULL; EDataCal *data_cal = NULL;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
skipping to change at line 1168 skipping to change at line 1153
/** /**
* e_cal_backend_set_data_cal: * e_cal_backend_set_data_cal:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @data_cal: an #EDataCal * @data_cal: an #EDataCal
* *
* Sets the #EDataCal for @backend. The #EDataCal is essentially the * Sets the #EDataCal for @backend. The #EDataCal is essentially the
* glue between incoming D-Bus requests and @backend's native API. * glue between incoming D-Bus requests and @backend's native API.
* *
* An #EDataCal should be set only once after @backend is first created. * An #EDataCal should be set only once after @backend is first created.
* *
* The @backend adds its own reference on the @data_cal.
*
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_set_data_cal (ECalBackend *backend, e_cal_backend_set_data_cal (ECalBackend *backend,
EDataCal *data_cal) EDataCal *data_cal)
{ {
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (E_IS_DATA_CAL (data_cal)); g_return_if_fail (E_IS_DATA_CAL (data_cal));
/* This should be set only once. Warn if not. */ /* This should be set only once. Warn if not. */
skipping to change at line 1194 skipping to change at line 1181
* e_cal_backend_ref_proxy_resolver: * e_cal_backend_ref_proxy_resolver:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* *
* Returns the #GProxyResolver for @backend (if applicable), as indicated * Returns the #GProxyResolver for @backend (if applicable), as indicated
* by the #ESourceAuthentication:proxy-uid of @backend's #EBackend:source * by the #ESourceAuthentication:proxy-uid of @backend's #EBackend:source
* or one of its ancestors. * or one of its ancestors.
* *
* The returned #GProxyResolver is referenced for thread-safety and must * The returned #GProxyResolver is referenced for thread-safety and must
* be unreferenced with g_object_unref() when finished with it. * be unreferenced with g_object_unref() when finished with it.
* *
* Returns: a #GProxyResolver, or %NULL * Returns: (transfer full) (nullable): a #GProxyResolver, or %NULL
* *
* Since: 3.12 * Since: 3.12
**/ **/
GProxyResolver * GProxyResolver *
e_cal_backend_ref_proxy_resolver (ECalBackend *backend) e_cal_backend_ref_proxy_resolver (ECalBackend *backend)
{ {
GProxyResolver *proxy_resolver = NULL; GProxyResolver *proxy_resolver = NULL;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
skipping to change at line 1221 skipping to change at line 1208
return proxy_resolver; return proxy_resolver;
} }
/** /**
* e_cal_backend_get_registry: * e_cal_backend_get_registry:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* *
* Returns the data source registry to which #EBackend:source belongs. * Returns the data source registry to which #EBackend:source belongs.
* *
* Returns: an #ESourceRegistry * Returns: (transfer none): an #ESourceRegistry
* *
* Since: 3.6 * Since: 3.6
**/ **/
ESourceRegistry * ESourceRegistry *
e_cal_backend_get_registry (ECalBackend *backend) e_cal_backend_get_registry (ECalBackend *backend)
{ {
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
return backend->priv->registry; return backend->priv->registry;
} }
skipping to change at line 1446 skipping to change at line 1433
e_cal_backend_get_backend_property (ECalBackend *backend, e_cal_backend_get_backend_property (ECalBackend *backend,
const gchar *prop_name) const gchar *prop_name)
{ {
ECalBackendClass *class; ECalBackendClass *class;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
g_return_val_if_fail (prop_name != NULL, NULL); g_return_val_if_fail (prop_name != NULL, NULL);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_val_if_fail (class != NULL, NULL); g_return_val_if_fail (class != NULL, NULL);
g_return_val_if_fail (class->get_backend_property != NULL, NULL); g_return_val_if_fail (class->impl_get_backend_property != NULL, NULL);
return class->get_backend_property (backend, prop_name); return class->impl_get_backend_property (backend, prop_name);
} }
/** /**
* e_cal_backend_add_view: * e_cal_backend_add_view:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @view: An #EDataCalView object. * @view: An #EDataCalView object.
* *
* Adds a view to the list of live views being run by the given backend. * Adds a view to the list of live views being run by the given backend.
* Doing so means that any listener on the view will get notified of any * Doing so means that any listener on the view will get notified of any
* change that affect the live view. * change that affect the live view.
skipping to change at line 1478 skipping to change at line 1465
g_mutex_lock (&backend->priv->views_mutex); g_mutex_lock (&backend->priv->views_mutex);
g_object_ref (view); g_object_ref (view);
backend->priv->views = g_list_append (backend->priv->views, view); backend->priv->views = g_list_append (backend->priv->views, view);
g_mutex_unlock (&backend->priv->views_mutex); g_mutex_unlock (&backend->priv->views_mutex);
} }
/** /**
* e_cal_backend_remove_view * e_cal_backend_remove_view:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @view: An #EDataCalView object, previously added with @ref e_cal_backend_add_ view. * @view: An #EDataCalView object, previously added with @ref e_cal_backend_add_ view.
* *
* Removes view from the list of live views for the backend. * Removes view from the list of live views for the backend.
* *
* Since: 3.2 * Since: 3.2
**/ **/
void void
e_cal_backend_remove_view (ECalBackend *backend, e_cal_backend_remove_view (ECalBackend *backend,
EDataCalView *view) EDataCalView *view)
skipping to change at line 1532 skipping to change at line 1519
* The views returned in the list are referenced for thread-safety. * The views returned in the list are referenced for thread-safety.
* They must each be unreferenced with g_object_unref() when finished * They must each be unreferenced with g_object_unref() when finished
* with them. Free the returned list itself with g_list_free(). * with them. Free the returned list itself with g_list_free().
* *
* An easy way to free the list properly in one step is as follows: * An easy way to free the list properly in one step is as follows:
* *
* |[ * |[
* g_list_free_full (list, g_object_unref); * g_list_free_full (list, g_object_unref);
* ]| * ]|
* *
* Returns: (element-type EDataCalView): a list of cal views * Returns: (element-type EDataCalView) (transfer full): a list of cal views
* *
* Since: 3.8 * Since: 3.8
**/ **/
GList * GList *
e_cal_backend_list_views (ECalBackend *backend) e_cal_backend_list_views (ECalBackend *backend)
{ {
GList *list; GList *list;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
skipping to change at line 1555 skipping to change at line 1542
/* XXX Use g_list_copy_deep() once we require GLib >= 2.34. */ /* XXX Use g_list_copy_deep() once we require GLib >= 2.34. */
list = g_list_copy (backend->priv->views); list = g_list_copy (backend->priv->views);
g_list_foreach (list, (GFunc) g_object_ref, NULL); g_list_foreach (list, (GFunc) g_object_ref, NULL);
g_mutex_unlock (&backend->priv->views_mutex); g_mutex_unlock (&backend->priv->views_mutex);
return list; return list;
} }
/** /**
* ECalBackendForeachViewFunc:
* @backend: an #ECalBackend
* @view: an #EDataCalView
* @user_data: user data for the function
*
* Callback function used by e_cal_backend_foreach_view().
*
* Returns: %TRUE, to continue, %FALSE to stop further processing.
*
* Since: 3.34
**/
/**
* e_cal_backend_foreach_view:
* @backend: an #ECalBackend
* @func: (scope call): an #ECalBackendForeachViewFunc function to call
* @user_data: (closure func): user data to pass to @func
*
* Calls @func for each existing view (as returned by e_cal_backend_list_views()
).
* The @func can return %FALSE to stop early.
*
* Returns: whether the call had been stopped by @func
*
* Since: 3.34
**/
gboolean
e_cal_backend_foreach_view (ECalBackend *backend,
ECalBackendForeachViewFunc func,
gpointer user_data)
{
GList *views, *link;
gboolean stopped = FALSE;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (func != NULL, FALSE);
views = e_cal_backend_list_views (backend);
for (link = views; link && !stopped; link = g_list_next (link)) {
stopped = !func (backend, link->data, user_data);
}
g_list_free_full (views, g_object_unref);
return stopped;
}
struct NotifyProgressData {
gboolean only_completed_views;
gint percent;
const gchar *message;
};
static gboolean
ecb_notify_progress_cb (ECalBackend *backend,
EDataCalView *view,
gpointer user_data)
{
struct NotifyProgressData *npd = user_data;
g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), FALSE);
g_return_val_if_fail (npd != NULL, FALSE);
if (!npd->only_completed_views || e_data_cal_view_is_completed (view))
e_data_cal_view_notify_progress (view, npd->percent, npd->message
);
return TRUE;
}
/**
* e_cal_backend_foreach_view_notify_progress:
* @backend: an #ECalBackend
* @only_completed_views: whether notify in completed views only
* @percent: percent complete
* @message: (nullable): message describing the operation in progress, or %NULL
*
* Notifies each view of the @backend about progress. When @only_completed_views
* is %TRUE, notifies only completed views.
*
* Since: 3.34
**/
void
e_cal_backend_foreach_view_notify_progress (ECalBackend *backend,
gboolean only_completed_views,
gint percent,
const gchar *message)
{
struct NotifyProgressData npd;
g_return_if_fail (E_IS_CAL_BACKEND (backend));
npd.only_completed_views = only_completed_views;
npd.percent = percent;
npd.message = message;
e_cal_backend_foreach_view (backend, ecb_notify_progress_cb, &npd);
}
/**
* e_cal_backend_open_sync: * e_cal_backend_open_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* "Opens" the @backend. Opening a backend is something of an outdated * "Opens" the @backend. Opening a backend is something of an outdated
* concept, but the operation is hanging around for a little while longer. * concept, but the operation is hanging around for a little while longer.
* This usually involves some custom initialization logic, and testing of * This usually involves some custom initialization logic, and testing of
* remote authentication if applicable. * remote authentication if applicable.
* *
skipping to change at line 1611 skipping to change at line 1697
GCancellable *cancellable) GCancellable *cancellable)
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->open != NULL); g_return_if_fail (class->impl_open != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
if (e_cal_backend_is_opened (backend)) { if (e_cal_backend_is_opened (backend)) {
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
e_backend_ensure_online_state_updated (E_BACKEND (backend), cance llable); e_backend_ensure_online_state_updated (E_BACKEND (backend), cance llable);
class->open (backend, data_cal, opid, cancellable, FALSE); class->impl_open (backend, data_cal, opid, cancellable);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_open: * e_cal_backend_open:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
skipping to change at line 1775 skipping to change at line 1861
EDataCal *data_cal; EDataCal *data_cal;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
if (class->refresh == NULL) { if (class->impl_refresh == NULL) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_SUPPORTED, E_CLIENT_ERROR_NOT_SUPPORTED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_SUPPORTED)); E_CLIENT_ERROR_NOT_SUPPORTED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else if (!e_cal_backend_is_opened (backend)) { } else if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->refresh (backend, data_cal, opid, cancellable); class->impl_refresh (backend, data_cal, opid, cancellable);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_refresh: * e_cal_backend_refresh:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
skipping to change at line 1945 skipping to change at line 2031
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->get_object != NULL); g_return_if_fail (class->impl_get_object != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->get_object ( class->impl_get_object (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->uid, async_context->uid,
async_context->rid); async_context->rid);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_get_object: * e_cal_backend_get_object:
skipping to change at line 2078 skipping to change at line 2164
g_warn_if_fail (g_queue_is_empty (&async_context->result_queue)); g_warn_if_fail (g_queue_is_empty (&async_context->result_queue));
return calobj; return calobj;
} }
/** /**
* e_cal_backend_get_object_list_sync: * e_cal_backend_get_object_list_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @query: a search query in S-expression format * @query: a search query in S-expression format
* @out_objects: a #GQueue in which to deposit results * @out_objects: (element-type utf8): a #GQueue in which to deposit results
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Obtains a set of iCalendar string instances which satisfy the criteria * Obtains a set of iCalendar string instances which satisfy the criteria
* specified in @query, and deposits them in @out_objects. * specified in @query, and deposits them in @out_objects.
* *
* The returned instances should be freed with g_free() when finished with them. * The returned instances should be freed with g_free() when finished with them.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* Note that an empty result set does not necessarily imply an error. * Note that an empty result set does not necessarily imply an error.
skipping to change at line 2139 skipping to change at line 2225
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->get_object_list != NULL); g_return_if_fail (class->impl_get_object_list != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->get_object_list ( class->impl_get_object_list (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->query); async_context->query);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_get_object_list: * e_cal_backend_get_object_list:
* @backend: an #ECalBackend * @backend: an #ECalBackend
skipping to change at line 2222 skipping to change at line 2308
cal_backend_dispatch_next_operation (backend); cal_backend_dispatch_next_operation (backend);
g_object_unref (simple); g_object_unref (simple);
} }
/** /**
* e_cal_backend_get_object_list_finish: * e_cal_backend_get_object_list_finish:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @result: a #GAsyncResult * @result: a #GAsyncResult
* @out_objects: a #GQueue in which to deposit results * @out_objects: (element-type utf8): a #GQueue in which to deposit results
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Finishes the operation started with e_cal_backend_get_object_list(). * Finishes the operation started with e_cal_backend_get_object_list().
* *
* The matching iCalendar instances are deposited in @out_objects. * The matching iCalendar instances are deposited in @out_objects.
* The returned instances should be freed with g_free() when finished with them. * The returned instances should be freed with g_free() when finished with them.
* *
* If an error occurred, the function will set @error and return %FALSE. * If an error occurred, the function will set @error and return %FALSE.
* Note that an empty result set does not necessarily imply an error. * Note that an empty result set does not necessarily imply an error.
* *
skipping to change at line 2270 skipping to change at line 2356
e_queue_transfer (&async_context->result_queue, out_objects); e_queue_transfer (&async_context->result_queue, out_objects);
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_get_free_busy_sync: * e_cal_backend_get_free_busy_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @start: start time * @start: start time
* @end: end time * @end: end time
* @users: a %NULL-terminated array of user strings * @users: (array zero-terminated=1): a %NULL-terminated array of user strings
* @out_freebusy: iCalendar strings with overall returned Free/Busy data * @out_freebusy: (element-type utf8): iCalendar strings with overall returned F
ree/Busy data
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Obtains a free/busy object for the list of @users in the time interval * Obtains a free/busy object for the list of @users in the time interval
* between @start and @end. * between @start and @end.
* *
* The free/busy results can be returned through the * The free/busy results can be returned through the
* e_data_cal_report_free_busy_data() function asynchronously. The out_freebusy * e_data_cal_report_free_busy_data() function asynchronously. The out_freebusy
* will contain all the returned data, possibly again, thus the client is * will contain all the returned data, possibly again, thus the client is
* responsible for the data merge, if needed. * responsible for the data merge, if needed.
skipping to change at line 2335 skipping to change at line 2421
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->get_free_busy != NULL); g_return_if_fail (class->impl_get_free_busy != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->get_free_busy ( class->impl_get_free_busy (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->string_list, async_context->string_list,
async_context->start, async_context->start,
async_context->end); async_context->end);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_get_free_busy: * e_cal_backend_get_free_busy:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @start: start time * @start: start time
* @end: end time * @end: end time
* @users: a %NULL-terminated array of user strings * @users: (array zero-terminated=1): a %NULL-terminated array of user strings
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously obtains a free/busy object for the list of @users in the * Asynchronously obtains a free/busy object for the list of @users in the
* time interval between @start and @end. * time interval between @start and @end.
* *
* When the operation is finished, @callback will be called. You can * When the operation is finished, @callback will be called. You can
* then call e_cal_backend_get_free_busy_finish() to get the result of * then call e_cal_backend_get_free_busy_finish() to get the result of
* the operation. * the operation.
skipping to change at line 2433 skipping to change at line 2519
cal_backend_dispatch_next_operation (backend); cal_backend_dispatch_next_operation (backend);
g_object_unref (simple); g_object_unref (simple);
} }
/** /**
* e_cal_backend_get_free_busy_finish: * e_cal_backend_get_free_busy_finish:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @result: a #GAsyncResult * @result: a #GAsyncResult
* @out_freebusy: iCalendar strings with overall returned Free/Busy data * @out_freebusy: (element-type utf8): iCalendar strings with overall returned F ree/Busy data
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Finishes the operation started with e_cal_backend_get_free_busy(). * Finishes the operation started with e_cal_backend_get_free_busy().
* *
* The free/busy results can be returned through the * The free/busy results can be returned through the
* e_data_cal_report_free_busy_data() function asynchronously. The out_freebusy * e_data_cal_report_free_busy_data() function asynchronously. The out_freebusy
* will contain all the returned data, possibly again, thus the client is * will contain all the returned data, possibly again, thus the client is
* responsible for the data merge, if needed. * responsible for the data merge, if needed.
* *
* If an error occurred, the function will set @error and return %FALSE. * If an error occurred, the function will set @error and return %FALSE.
skipping to change at line 2493 skipping to change at line 2579
if (out_freebusy) if (out_freebusy)
*out_freebusy = g_slist_reverse (ical_strings); *out_freebusy = g_slist_reverse (ical_strings);
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_create_objects_sync: * e_cal_backend_create_objects_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobjs: a %NULL-terminated array of iCalendar strings * @calobjs: a %NULL-terminated array of iCalendar strings
* @opflags: bit-or of #ECalOperationFlags
* @out_uids: a #GQueue in which to deposit results * @out_uids: a #GQueue in which to deposit results
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Creates one or more new iCalendar objects from @calobjs, and deposits * Creates one or more new iCalendar objects from @calobjs, and deposits
* the unique ID string for each newly-created object in @out_uids. * the unique ID string for each newly-created object in @out_uids.
* *
* Free the returned ID strings with g_free() when finished with them. * Free the returned ID strings with g_free() when finished with them.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* *
* Returns: %TRUE on success, %FALSE on failure * Returns: %TRUE on success, %FALSE on failure
* *
* Since: 3.10 * Since: 3.10
**/ **/
gboolean gboolean
e_cal_backend_create_objects_sync (ECalBackend *backend, e_cal_backend_create_objects_sync (ECalBackend *backend,
const gchar * const *calobjs, const gchar * const *calobjs,
guint32 opflags,
GQueue *out_uids, GQueue *out_uids,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gboolean success; gboolean success;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (calobjs != NULL, FALSE); g_return_val_if_fail (calobjs != NULL, FALSE);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_create_objects ( e_cal_backend_create_objects (
backend, calobjs, cancellable, backend, calobjs, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
success = e_cal_backend_create_objects_finish ( success = e_cal_backend_create_objects_finish (
backend, result, out_uids, error); backend, result, out_uids, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return success; return success;
skipping to change at line 2559 skipping to change at line 2647
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (class->create_objects == NULL) { if (class->impl_create_objects == NULL) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_SUPPORTED, E_CLIENT_ERROR_NOT_SUPPORTED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_SUPPORTED)); E_CLIENT_ERROR_NOT_SUPPORTED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else if (!e_cal_backend_is_opened (backend)) { } else if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->create_objects ( class->impl_create_objects (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->string_list); async_context->string_list, async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_create_objects: * e_cal_backend_create_objects:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobjs: a %NULL-terminated array of iCalendar strings * @calobjs: a %NULL-terminated array of iCalendar strings
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisifed * @callback: a #GAsyncReadyCallback to call when the request is satisifed
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously creates one or more new iCalendar objects from @calobjs. * Asynchronously creates one or more new iCalendar objects from @calobjs.
* *
* When the operation is finished, @callback will be called. You can then * When the operation is finished, @callback will be called. You can then
* call e_cal_backend_create_objects_finish() to get the result of the * call e_cal_backend_create_objects_finish() to get the result of the
* operation. * operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_create_objects (ECalBackend *backend, e_cal_backend_create_objects (ECalBackend *backend,
const gchar * const *calobjs, const gchar * const *calobjs,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
GSList *list = NULL; GSList *list = NULL;
gint ii; gint ii;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (calobjs != NULL); g_return_if_fail (calobjs != NULL);
for (ii = 0; calobjs[ii] != NULL; ii++) for (ii = 0; calobjs[ii] != NULL; ii++)
list = g_slist_prepend (list, g_strdup (calobjs[ii])); list = g_slist_prepend (list, g_strdup (calobjs[ii]));
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->string_list = g_slist_reverse (list); async_context->string_list = g_slist_reverse (list);
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_create_objects); e_cal_backend_create_objects);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 2715 skipping to change at line 2806
g_object_unref (component); g_object_unref (component);
} }
g_queue_free (string_queue); g_queue_free (string_queue);
g_queue_free (component_queue); g_queue_free (component_queue);
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_modify_objects: * e_cal_backend_modify_objects_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobjs: a %NULL-terminated array of iCalendar strings * @calobjs: a %NULL-terminated array of iCalendar strings
* @mod: modification type for recurrences * @mod: modification type for recurrences
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Modifies one or more iCalendar objects according to @calobjs and @mod. * Modifies one or more iCalendar objects according to @calobjs and @mod.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* *
* Returns: %TRUE on success, %FALSE on failure * Returns: %TRUE on success, %FALSE on failure
* *
* Since: 3.10 * Since: 3.10
**/ **/
gboolean gboolean
e_cal_backend_modify_objects_sync (ECalBackend *backend, e_cal_backend_modify_objects_sync (ECalBackend *backend,
const gchar * const *calobjs, const gchar * const *calobjs,
ECalObjModType mod, ECalObjModType mod,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gboolean success; gboolean success;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (calobjs != NULL, FALSE); g_return_val_if_fail (calobjs != NULL, FALSE);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_modify_objects ( e_cal_backend_modify_objects (
backend, calobjs, mod, cancellable, backend, calobjs, mod, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
success = e_cal_backend_modify_objects_finish ( success = e_cal_backend_modify_objects_finish (
backend, result, error); backend, result, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return success; return success;
skipping to change at line 2781 skipping to change at line 2874
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (class->modify_objects == NULL) { if (class->impl_modify_objects == NULL) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_SUPPORTED, E_CLIENT_ERROR_NOT_SUPPORTED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_SUPPORTED)); E_CLIENT_ERROR_NOT_SUPPORTED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else if (!e_cal_backend_is_opened (backend)) { } else if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->modify_objects ( class->impl_modify_objects (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->string_list, async_context->string_list,
async_context->mod); async_context->mod,
async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_modify_objects: * e_cal_backend_modify_objects:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobjs: a %NULL-terminated array of iCalendar strings * @calobjs: a %NULL-terminated array of iCalendar strings
* @mod: modification type for recurrences * @mod: modification type for recurrences
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously modifies one or more iCalendar objects according to * Asynchronously modifies one or more iCalendar objects according to
* @calobjs and @mod. * @calobjs and @mod.
* *
* When the operation is finished, @callback will be called. You can then * When the operation is finished, @callback will be called. You can then
* call e_cal_backend_modify_objects_finish() to get the result of the * call e_cal_backend_modify_objects_finish() to get the result of the
* operation. * operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_modify_objects (ECalBackend *backend, e_cal_backend_modify_objects (ECalBackend *backend,
const gchar * const *calobjs, const gchar * const *calobjs,
ECalObjModType mod, ECalObjModType mod,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
GSList *list = NULL; GSList *list = NULL;
gint ii; gint ii;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (calobjs != NULL); g_return_if_fail (calobjs != NULL);
for (ii = 0; calobjs[ii] != NULL; ii++) for (ii = 0; calobjs[ii] != NULL; ii++)
list = g_slist_prepend (list, g_strdup (calobjs[ii])); list = g_slist_prepend (list, g_strdup (calobjs[ii]));
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->string_list = g_slist_reverse (list); async_context->string_list = g_slist_reverse (list);
async_context->mod = mod; async_context->mod = mod;
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_modify_objects); e_cal_backend_modify_objects);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 2950 skipping to change at line 3047
g_warn_if_fail (g_queue_is_empty (new_component_queue)); g_warn_if_fail (g_queue_is_empty (new_component_queue));
g_queue_free (new_component_queue); g_queue_free (new_component_queue);
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_remove_objects_sync: * e_cal_backend_remove_objects_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @component_ids: a #GList of #ECalComponentId structs * @component_ids: (element-type ECalComponentId): a #GList of #ECalComponentId structs
* @mod: modification type for recurrences * @mod: modification type for recurrences
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Removes one or more iCalendar objects according to @component_ids and @mod. * Removes one or more iCalendar objects according to @component_ids and @mod.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* *
* Returns: %TRUE on success, %FALSE on failure * Returns: %TRUE on success, %FALSE on failure
* *
* Since: 3.10 * Since: 3.10
**/ **/
gboolean gboolean
e_cal_backend_remove_objects_sync (ECalBackend *backend, e_cal_backend_remove_objects_sync (ECalBackend *backend,
GList *component_ids, GList *component_ids,
ECalObjModType mod, ECalObjModType mod,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gboolean success; gboolean success;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (component_ids != NULL, FALSE); g_return_val_if_fail (component_ids != NULL, FALSE);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_remove_objects ( e_cal_backend_remove_objects (
backend, component_ids, mod, cancellable, backend, component_ids, mod, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
success = e_cal_backend_remove_objects_finish ( success = e_cal_backend_remove_objects_finish (
backend, result, error); backend, result, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return success; return success;
skipping to change at line 3008 skipping to change at line 3107
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->remove_objects != NULL); g_return_if_fail (class->impl_remove_objects != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->remove_objects ( class->impl_remove_objects (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->compid_list, async_context->compid_list,
async_context->mod); async_context->mod,
async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_remove_objects: * e_cal_backend_remove_objects:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @component_ids: a #GList of #ECalComponentId structs * @component_ids: (element-type ECalComponentId): a #GList of #ECalComponentId structs
* @mod: modification type for recurrences * @mod: modification type for recurrences
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously removes one or more iCalendar objects according to * Asynchronously removes one or more iCalendar objects according to
* @component_ids and @mod. * @component_ids and @mod.
* *
* When the operation is finished, @callback will be called. You can then * When the operation is finished, @callback will be called. You can then
* call e_cal_backend_remove_objects_finish() to get the result of the * call e_cal_backend_remove_objects_finish() to get the result of the
* operation. * operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_remove_objects (ECalBackend *backend, e_cal_backend_remove_objects (ECalBackend *backend,
GList *component_ids, GList *component_ids,
ECalObjModType mod, ECalObjModType mod,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
GSList *list = NULL; GSList *list = NULL;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (component_ids != NULL); g_return_if_fail (component_ids != NULL);
while (component_ids != NULL) { while (component_ids != NULL) {
ECalComponentId *id = component_ids->data; ECalComponentId *id = component_ids->data;
list = g_slist_prepend (list, e_cal_component_id_copy (id)); list = g_slist_prepend (list, e_cal_component_id_copy (id));
component_ids = g_list_next (component_ids); component_ids = g_list_next (component_ids);
} }
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->compid_list = g_slist_reverse (list); async_context->compid_list = g_slist_reverse (list);
async_context->mod = mod; async_context->mod = mod;
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_remove_objects); e_cal_backend_remove_objects);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 3168 skipping to change at line 3271
ECalComponent *new_component = NULL; ECalComponent *new_component = NULL;
component_id = g_queue_pop_head (component_id_queue); component_id = g_queue_pop_head (component_id_queue);
old_component = g_queue_pop_head (old_component_queue); old_component = g_queue_pop_head (old_component_queue);
if (new_component_queue != NULL) if (new_component_queue != NULL)
new_component = g_queue_pop_head (new_component_queue); new_component = g_queue_pop_head (new_component_queue);
e_cal_backend_notify_component_removed ( e_cal_backend_notify_component_removed (
backend, component_id, old_component, new_component); backend, component_id, old_component, new_component);
e_cal_component_free_id (component_id); e_cal_component_id_free (component_id);
g_clear_object (&old_component); g_clear_object (&old_component);
g_clear_object (&new_component); g_clear_object (&new_component);
} }
g_warn_if_fail (g_queue_is_empty (component_id_queue)); g_warn_if_fail (g_queue_is_empty (component_id_queue));
g_queue_free (component_id_queue); g_queue_free (component_id_queue);
g_warn_if_fail (g_queue_is_empty (old_component_queue)); g_warn_if_fail (g_queue_is_empty (old_component_queue));
g_queue_free (old_component_queue); g_queue_free (old_component_queue);
skipping to change at line 3191 skipping to change at line 3294
g_queue_free (new_component_queue); g_queue_free (new_component_queue);
} }
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_receive_objects_sync: * e_cal_backend_receive_objects_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobj: an iCalendar string * @calobj: an iCalendar string
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Receives the set of iCalendar objects specified by @calobj. This is used * Receives the set of iCalendar objects specified by @calobj. This is used
* for iTIP confirmation and cancellation messages for scheduled meetings. * for iTIP confirmation and cancellation messages for scheduled meetings.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* *
* Returns: %TRUE on success, %FALSE on failure * Returns: %TRUE on success, %FALSE on failure
* *
* Since: 3.10 * Since: 3.10
**/ **/
gboolean gboolean
e_cal_backend_receive_objects_sync (ECalBackend *backend, e_cal_backend_receive_objects_sync (ECalBackend *backend,
const gchar *calobj, const gchar *calobj,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gboolean success; gboolean success;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (calobj != NULL, FALSE); g_return_val_if_fail (calobj != NULL, FALSE);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_receive_objects ( e_cal_backend_receive_objects (
backend, calobj, cancellable, backend, calobj, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
success = e_cal_backend_receive_objects_finish ( success = e_cal_backend_receive_objects_finish (
backend, result, error); backend, result, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return success; return success;
skipping to change at line 3247 skipping to change at line 3352
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->receive_objects != NULL); g_return_if_fail (class->impl_receive_objects != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->receive_objects ( class->impl_receive_objects (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->calobj); async_context->calobj,
async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_receive_objects: * e_cal_backend_receive_objects:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobj: an iCalendar string * @calobj: an iCalendar string
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously receives the set of iCalendar objects specified by * Asynchronously receives the set of iCalendar objects specified by
* @calobj. This is used for iTIP confirmation and cancellation messages * @calobj. This is used for iTIP confirmation and cancellation messages
* for scheduled meetings. * for scheduled meetings.
* *
* When the operation is finished, @callback will be called. You can then * When the operation is finished, @callback will be called. You can then
* call e_cal_backend_receive_objects_finish() to get the result of the * call e_cal_backend_receive_objects_finish() to get the result of the
* operation. * operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_receive_objects (ECalBackend *backend, e_cal_backend_receive_objects (ECalBackend *backend,
const gchar *calobj, const gchar *calobj,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (calobj != NULL); g_return_if_fail (calobj != NULL);
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->calobj = g_strdup (calobj); async_context->calobj = g_strdup (calobj);
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_receive_objects); e_cal_backend_receive_objects);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 3365 skipping to change at line 3474
cal_backend_unblock_operations (backend, simple); cal_backend_unblock_operations (backend, simple);
/* Assume success unless a GError is set. */ /* Assume success unless a GError is set. */
return !g_simple_async_result_propagate_error (simple, error); return !g_simple_async_result_propagate_error (simple, error);
} }
/** /**
* e_cal_backend_send_objects_sync: * e_cal_backend_send_objects_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobj: an iCalendar string * @calobj: an iCalendar string
* @opflags: bit-or of #ECalOperationFlags
* @out_users: a #GQueue in which to deposit results * @out_users: a #GQueue in which to deposit results
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Sends meeting information in @calobj. The @backend may modify @calobj * Sends meeting information in @calobj. The @backend may modify @calobj
* and send meeting information only to particular users. The function * and send meeting information only to particular users. The function
* returns the (maybe) modified @calobj and deposits the list of users the * returns the (maybe) modified @calobj and deposits the list of users the
* meeting information was sent (to be send) to in @out_users. * meeting information was sent (to be send) to in @out_users.
* *
* The returned pointer should be freed with g_free(), when no londer needed. * The returned pointer should be freed with g_free(), when no londer needed.
* *
* If an error occurs, the function will set @error and return %NULL. * If an error occurs, the function will set @error and return %NULL.
* *
* Returns: a vCalendar string, or %NULL * Returns: a vCalendar string, or %NULL
* *
* Since: 3.10 * Since: 3.10
**/ **/
gchar * gchar *
e_cal_backend_send_objects_sync (ECalBackend *backend, e_cal_backend_send_objects_sync (ECalBackend *backend,
const gchar *calobj, const gchar *calobj,
guint32 opflags,
GQueue *out_users, GQueue *out_users,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gchar *out_calobj; gchar *out_calobj;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
g_return_val_if_fail (calobj != NULL, NULL); g_return_val_if_fail (calobj != NULL, NULL);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_send_objects ( e_cal_backend_send_objects (
backend, calobj, cancellable, backend, calobj, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
out_calobj = e_cal_backend_send_objects_finish ( out_calobj = e_cal_backend_send_objects_finish (
backend, result, out_users, error); backend, result, out_users, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return out_calobj; return out_calobj;
skipping to change at line 3427 skipping to change at line 3538
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->send_objects != NULL); g_return_if_fail (class->impl_send_objects != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->send_objects ( class->impl_send_objects (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->calobj); async_context->calobj,
async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_send_objects: * e_cal_backend_send_objects:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @calobj: an iCalendar string * @calobj: an iCalendar string
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously sends meeting information in @calobj. The @backend may * Asynchronously sends meeting information in @calobj. The @backend may
* modify @calobj and send meeting information only to particular users. * modify @calobj and send meeting information only to particular users.
* *
* When the operation is finished, @callback will be called. You can then * When the operation is finished, @callback will be called. You can then
* call e_cal_backend_send_objects_finish() to get the result of the operation. * call e_cal_backend_send_objects_finish() to get the result of the operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_send_objects (ECalBackend *backend, e_cal_backend_send_objects (ECalBackend *backend,
const gchar *calobj, const gchar *calobj,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (calobj != NULL); g_return_if_fail (calobj != NULL);
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->calobj = g_strdup (calobj); async_context->calobj = g_strdup (calobj);
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_send_objects); e_cal_backend_send_objects);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 3625 skipping to change at line 3740
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->get_attachment_uris != NULL); g_return_if_fail (class->impl_get_attachment_uris != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->get_attachment_uris ( class->impl_get_attachment_uris (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->uid, async_context->uid,
async_context->rid); async_context->rid);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_get_attachment_uris: * e_cal_backend_get_attachment_uris:
skipping to change at line 3762 skipping to change at line 3877
return TRUE; return TRUE;
} }
/** /**
* e_cal_backend_discard_alarm_sync: * e_cal_backend_discard_alarm_sync:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @uid: a unique ID for an iCalendar object * @uid: a unique ID for an iCalendar object
* @rid: a recurrence ID, or %NULL * @rid: a recurrence ID, or %NULL
* @alarm_uid: a unique ID for an iCalendar VALARM object * @alarm_uid: a unique ID for an iCalendar VALARM object
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @error: return location for a #GError, or %NULL * @error: return location for a #GError, or %NULL
* *
* Discards the VALARM object with a unique ID of @alarm_uid from the * Discards the VALARM object with a unique ID of @alarm_uid from the
* iCalendar object identified by @uid and, optionally, @rid. * iCalendar object identified by @uid and, optionally, @rid.
* *
* If an error occurs, the function will set @error and return %FALSE. * If an error occurs, the function will set @error and return %FALSE.
* *
* Returns: %TRUE on success, %FALSE on failure * Returns: %TRUE on success, %FALSE on failure
* *
* Since: 3.10 * Since: 3.10
**/ **/
gboolean gboolean
e_cal_backend_discard_alarm_sync (ECalBackend *backend, e_cal_backend_discard_alarm_sync (ECalBackend *backend,
const gchar *uid, const gchar *uid,
const gchar *rid, const gchar *rid,
const gchar *alarm_uid, const gchar *alarm_uid,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EAsyncClosure *closure; EAsyncClosure *closure;
GAsyncResult *result; GAsyncResult *result;
gboolean success; gboolean success;
g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE); g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
g_return_val_if_fail (uid != NULL, FALSE); g_return_val_if_fail (uid != NULL, FALSE);
/* rid can be NULL */ /* rid can be NULL */
g_return_val_if_fail (alarm_uid != NULL, FALSE); g_return_val_if_fail (alarm_uid != NULL, FALSE);
closure = e_async_closure_new (); closure = e_async_closure_new ();
e_cal_backend_discard_alarm ( e_cal_backend_discard_alarm (
backend, uid, rid, alarm_uid, cancellable, backend, uid, rid, alarm_uid, opflags, cancellable,
e_async_closure_callback, closure); e_async_closure_callback, closure);
result = e_async_closure_wait (closure); result = e_async_closure_wait (closure);
success = e_cal_backend_discard_alarm_finish ( success = e_cal_backend_discard_alarm_finish (
backend, result, error); backend, result, error);
e_async_closure_free (closure); e_async_closure_free (closure);
return success; return success;
skipping to change at line 3828 skipping to change at line 3945
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (class->discard_alarm == NULL) { if (class->impl_discard_alarm == NULL) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_SUPPORTED, E_CLIENT_ERROR_NOT_SUPPORTED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_SUPPORTED)); E_CLIENT_ERROR_NOT_SUPPORTED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else if (!e_cal_backend_is_opened (backend)) { } else if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->discard_alarm ( class->impl_discard_alarm (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->uid, async_context->uid,
async_context->rid, async_context->rid,
async_context->alarm_uid); async_context->alarm_uid,
async_context->opflags);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_discard_alarm: * e_cal_backend_discard_alarm:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @uid: a unique ID for an iCalendar object * @uid: a unique ID for an iCalendar object
* @rid: a recurrence ID, or %NULL * @rid: a recurrence ID, or %NULL
* @alarm_uid: a unique ID for an iCalendar VALARM object * @alarm_uid: a unique ID for an iCalendar VALARM object
* @opflags: bit-or of #ECalOperationFlags
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously discards the VALARM object with a unique ID of @alarm_uid * Asynchronously discards the VALARM object with a unique ID of @alarm_uid
* from the iCalendar object identified by @uid and, optionally, @rid. * from the iCalendar object identified by @uid and, optionally, @rid.
* *
* When the operation is finished, @callback will be called. You can * When the operation is finished, @callback will be called. You can
* then call e_cal_backend_discard_alarm_finish() to get the result of * then call e_cal_backend_discard_alarm_finish() to get the result of
* the operation. * the operation.
* *
* Since: 3.10 * Since: 3.10
**/ **/
void void
e_cal_backend_discard_alarm (ECalBackend *backend, e_cal_backend_discard_alarm (ECalBackend *backend,
const gchar *uid, const gchar *uid,
const gchar *rid, const gchar *rid,
const gchar *alarm_uid, const gchar *alarm_uid,
guint32 opflags,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
AsyncContext *async_context; AsyncContext *async_context;
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_return_if_fail (uid != NULL); g_return_if_fail (uid != NULL);
/* rid can be NULL */ /* rid can be NULL */
g_return_if_fail (alarm_uid != NULL); g_return_if_fail (alarm_uid != NULL);
async_context = g_slice_new0 (AsyncContext); async_context = g_slice_new0 (AsyncContext);
async_context->uid = g_strdup (uid); async_context->uid = g_strdup (uid);
async_context->rid = g_strdup (rid); async_context->rid = g_strdup (rid);
async_context->alarm_uid = g_strdup (alarm_uid); async_context->alarm_uid = g_strdup (alarm_uid);
async_context->opflags = opflags;
simple = g_simple_async_result_new ( simple = g_simple_async_result_new (
G_OBJECT (backend), callback, user_data, G_OBJECT (backend), callback, user_data,
e_cal_backend_discard_alarm); e_cal_backend_discard_alarm);
g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_check_cancellable (simple, cancellable);
g_simple_async_result_set_op_res_gpointer ( g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free); simple, async_context, (GDestroyNotify) async_context_free);
skipping to change at line 4012 skipping to change at line 4133
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->get_timezone != NULL); g_return_if_fail (class->impl_get_timezone != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->get_timezone ( class->impl_get_timezone (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->tzid); async_context->tzid);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_get_timezone: * e_cal_backend_get_timezone:
* @backend: an #ECalBackend * @backend: an #ECalBackend
skipping to change at line 4199 skipping to change at line 4320
{ {
ECalBackend *backend; ECalBackend *backend;
ECalBackendClass *class; ECalBackendClass *class;
EDataCal *data_cal; EDataCal *data_cal;
AsyncContext *async_context; AsyncContext *async_context;
backend = E_CAL_BACKEND (source_object); backend = E_CAL_BACKEND (source_object);
class = E_CAL_BACKEND_GET_CLASS (backend); class = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (class != NULL); g_return_if_fail (class != NULL);
g_return_if_fail (class->add_timezone != NULL); g_return_if_fail (class->impl_add_timezone != NULL);
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
g_return_if_fail (data_cal != NULL); g_return_if_fail (data_cal != NULL);
async_context = g_simple_async_result_get_op_res_gpointer (simple); async_context = g_simple_async_result_get_op_res_gpointer (simple);
if (!e_cal_backend_is_opened (backend)) { if (!e_cal_backend_is_opened (backend)) {
g_simple_async_result_set_error ( g_simple_async_result_set_error (
simple, E_CLIENT_ERROR, simple, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_OPENED, E_CLIENT_ERROR_NOT_OPENED,
"%s", e_client_error_to_string ( "%s", e_client_error_to_string (
E_CLIENT_ERROR_NOT_OPENED)); E_CLIENT_ERROR_NOT_OPENED));
g_simple_async_result_complete_in_idle (simple); g_simple_async_result_complete_in_idle (simple);
} else { } else {
guint32 opid; guint32 opid;
opid = cal_backend_stash_operation (backend, simple); opid = cal_backend_stash_operation (backend, simple);
class->add_timezone ( class->impl_add_timezone (
backend, data_cal, opid, cancellable, backend, data_cal, opid, cancellable,
async_context->tzobject); async_context->tzobject);
} }
g_object_unref (data_cal); g_object_unref (data_cal);
} }
/** /**
* e_cal_backend_add_timezone * e_cal_backend_add_timezone:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @tzobject: an iCalendar VTIMEZONE string * @tzobject: an iCalendar VTIMEZONE string
* @cancellable: optional #GCancellable object, or %NULL * @cancellable: optional #GCancellable object, or %NULL
* @callback: a #GAsyncReadyCallback to call when the request is satisfied * @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: data to pass to the callback function * @user_data: data to pass to the callback function
* *
* Asynchronously adds the timezone described by @tzobject to @backend. * Asynchronously adds the timezone described by @tzobject to @backend.
* *
* When the operation is finished, @callback will be called. You can * When the operation is finished, @callback will be called. You can
* then call e_cal_backend_add_timezone_finish() to get the result of * then call e_cal_backend_add_timezone_finish() to get the result of
skipping to change at line 4331 skipping to change at line 4452
e_cal_backend_start_view (ECalBackend *backend, e_cal_backend_start_view (ECalBackend *backend,
EDataCalView *view) EDataCalView *view)
{ {
ECalBackendClass *klass; ECalBackendClass *klass;
g_return_if_fail (backend != NULL); g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
klass = E_CAL_BACKEND_GET_CLASS (backend); klass = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (klass != NULL); g_return_if_fail (klass != NULL);
g_return_if_fail (klass->start_view != NULL); g_return_if_fail (klass->impl_start_view != NULL);
klass->start_view (backend, view); klass->impl_start_view (backend, view);
} }
/** /**
* e_cal_backend_stop_view: * e_cal_backend_stop_view:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @view: The view to be stopped. * @view: The view to be stopped.
* *
* Stops a previously started live view on the given backend. * Stops a previously started live view on the given backend.
* *
* Since: 3.2 * Since: 3.2
skipping to change at line 4358 skipping to change at line 4479
{ {
ECalBackendClass *klass; ECalBackendClass *klass;
g_return_if_fail (backend != NULL); g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend)); g_return_if_fail (E_IS_CAL_BACKEND (backend));
klass = E_CAL_BACKEND_GET_CLASS (backend); klass = E_CAL_BACKEND_GET_CLASS (backend);
g_return_if_fail (klass != NULL); g_return_if_fail (klass != NULL);
/* backward compatibility, do not force each backend define this function */ /* backward compatibility, do not force each backend define this function */
if (klass->stop_view) if (klass->impl_stop_view)
klass->stop_view (backend, view); klass->impl_stop_view (backend, view);
} }
/** /**
* e_cal_backend_notify_component_created: * e_cal_backend_notify_component_created:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @component: the newly created #ECalComponent * @component: the newly created #ECalComponent
* *
* Notifies each of the backend's listeners about a new object. * Notifies each of the backend's listeners about a new object.
* *
* Uses the #EDataCalView's fields-of-interest to filter out unwanted * Uses the #EDataCalView's fields-of-interest to filter out unwanted
skipping to change at line 4412 skipping to change at line 4533
if (old_component) if (old_component)
old_match = e_data_cal_view_component_matches (view, old_componen t); old_match = e_data_cal_view_component_matches (view, old_componen t);
new_match = e_data_cal_view_component_matches (view, new_component); new_match = e_data_cal_view_component_matches (view, new_component);
if (old_match && new_match) if (old_match && new_match)
e_data_cal_view_notify_components_modified_1 (view, new_component ); e_data_cal_view_notify_components_modified_1 (view, new_component );
else if (new_match) else if (new_match)
e_data_cal_view_notify_components_added_1 (view, new_component); e_data_cal_view_notify_components_added_1 (view, new_component);
else if (old_match) { else if (old_match) {
ECalComponentId *id = e_cal_component_get_id (old_component); ECalComponentId *id = e_cal_component_get_id (old_component);
e_data_cal_view_notify_objects_removed_1 (view, id); e_data_cal_view_notify_objects_removed_1 (view, id);
e_cal_component_free_id (id); e_cal_component_id_free (id);
} }
} }
/** /**
* e_cal_backend_notify_component_modified: * e_cal_backend_notify_component_modified:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @old_component: the #ECalComponent before the modification * @old_component: the #ECalComponent before the modification
* @new_component: the #ECalComponent after the modification * @new_component: the #ECalComponent after the modification
* *
* Notifies each of the backend's listeners about a modified object. * Notifies each of the backend's listeners about a modified object.
skipping to change at line 4560 skipping to change at line 4680
data_cal = e_cal_backend_ref_data_cal (backend); data_cal = e_cal_backend_ref_data_cal (backend);
if (data_cal != NULL) { if (data_cal != NULL) {
e_data_cal_report_backend_property_changed (data_cal, prop_name, prop_value ? prop_value : ""); e_data_cal_report_backend_property_changed (data_cal, prop_name, prop_value ? prop_value : "");
g_object_unref (data_cal); g_object_unref (data_cal);
} }
} }
/** /**
* e_cal_backend_empty_cache:
* @backend: an #ECalBackend
* @cache: Backend's cache to empty.
*
* Empties backend's cache with all notifications and so on, thus all listening
* will know there is nothing in this backend.
*
* Since: 2.28
**/
void
e_cal_backend_empty_cache (ECalBackend *backend,
ECalBackendCache *cache)
{
GList *comps_in_cache;
g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend));
if (!cache)
return;
g_return_if_fail (E_IS_CAL_BACKEND_CACHE (cache));
e_file_cache_freeze_changes (E_FILE_CACHE (cache));
for (comps_in_cache = e_cal_backend_cache_get_components (cache);
comps_in_cache;
comps_in_cache = comps_in_cache->next) {
ECalComponentId *id;
ECalComponent *comp = comps_in_cache->data;
id = e_cal_component_get_id (comp);
if (id) {
e_cal_backend_cache_remove_component (cache, id->uid, id-
>rid);
e_cal_backend_notify_component_removed (backend, id, comp
, NULL);
e_cal_component_free_id (id);
}
g_object_unref (comp);
}
g_list_free (comps_in_cache);
e_file_cache_thaw_changes (E_FILE_CACHE (cache));
}
/**
* e_cal_backend_prepare_for_completion: * e_cal_backend_prepare_for_completion:
* @backend: an #ECalBackend * @backend: an #ECalBackend
* @opid: an operation ID given to #EDataCal * @opid: an operation ID given to #EDataCal
* @result_queue: return location for a #GQueue, or %NULL * @result_queue: return location for a #GQueue, or %NULL
* *
* Obtains the #GSimpleAsyncResult for @opid and sets @result_queue as a * Obtains the #GSimpleAsyncResult for @opid and sets @result_queue as a
* place to deposit results prior to completing the #GSimpleAsyncResult. * place to deposit results prior to completing the #GSimpleAsyncResult.
* *
* <note> * <note>
* <para> * <para>
 End of changes. 133 change blocks. 
192 lines changed or deleted 266 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)