core/manager: Also refresh collections

Add on_collection_source_refreshed() callback. Track collection
source refresh in clients_synchronizing. Refresh collection sources
before calendar clients. Fix PROP_SYNCHRONIZING state by waiting for
all async ops.
This commit is contained in:
voyage200
2026-03-03 20:07:18 -03:00
parent f7d552aaeb
commit 9f956c93d4
+44
View File
@@ -159,6 +159,31 @@ source_changed (GcalManager *self,
GCAL_EXIT;
}
static void
on_collection_source_refreshed (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GcalManager *self = GCAL_MANAGER (user_data);
GError *error = NULL;
GCAL_ENTRY;
if (!e_source_registry_refresh_backend_finish (E_SOURCE_REGISTRY (source_object), result, &error))
{
/* FIXME: do something when there was some error */
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("Error refreshing collection source backend: %s", error->message);
g_clear_error (&error);
}
self->clients_synchronizing--;
if (self->clients_synchronizing == 0)
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SYNCHRONIZING]);
GCAL_EXIT;
}
static void
on_client_refreshed (GObject *source_object,
GAsyncResult *result,
@@ -955,6 +980,7 @@ gcal_manager_save_source (GcalManager *self,
void
gcal_manager_refresh (GcalManager *self)
{
g_autolist(ESource) collections = NULL;
GList *clients;
GList *l;
@@ -962,6 +988,24 @@ gcal_manager_refresh (GcalManager *self)
g_return_if_fail (GCAL_IS_MANAGER (self));
/* First, refresh collection sources to get latest calendar list */
collections = e_source_registry_list_sources (self->source_registry, E_SOURCE_EXTENSION_COLLECTION);
for (GList *sl = collections; sl != NULL; sl = sl->next)
{
ESource *source = sl->data;
if (!e_source_registry_check_enabled (self->source_registry, source))
continue;
self->clients_synchronizing++;
e_source_registry_refresh_backend (self->source_registry,
e_source_get_uid (source),
NULL,
on_collection_source_refreshed,
self);
}
clients = g_hash_table_get_values (self->clients);
/* refresh clients */