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:
@@ -159,6 +159,31 @@ source_changed (GcalManager *self,
|
|||||||
GCAL_EXIT;
|
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
|
static void
|
||||||
on_client_refreshed (GObject *source_object,
|
on_client_refreshed (GObject *source_object,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
@@ -955,6 +980,7 @@ gcal_manager_save_source (GcalManager *self,
|
|||||||
void
|
void
|
||||||
gcal_manager_refresh (GcalManager *self)
|
gcal_manager_refresh (GcalManager *self)
|
||||||
{
|
{
|
||||||
|
g_autolist(ESource) collections = NULL;
|
||||||
GList *clients;
|
GList *clients;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
@@ -962,6 +988,24 @@ gcal_manager_refresh (GcalManager *self)
|
|||||||
|
|
||||||
g_return_if_fail (GCAL_IS_MANAGER (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);
|
clients = g_hash_table_get_values (self->clients);
|
||||||
|
|
||||||
/* refresh clients */
|
/* refresh clients */
|
||||||
|
|||||||
Reference in New Issue
Block a user