manager: defer adding client to the internal hash

Wait until the client is opened and connected to add it to the internal
hash, so GcalManager::get_sources work properly.
This commit is contained in:
Erick Pérez Castellanos
2014-12-08 11:21:14 -05:00
parent e62f48bfea
commit 98e4b44a7d
+3 -8
View File
@@ -208,12 +208,6 @@ load_source (GcalManager *manager,
if (g_hash_table_lookup (priv->clients, source) == NULL)
{
GcalManagerUnit *unit;
unit = g_new0 (GcalManagerUnit, 1);
g_hash_table_insert (priv->clients, source, unit);
/* NULL: because maybe the operation cannot be really cancelled */
e_cal_client_connect (source,
E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL,
@@ -248,14 +242,15 @@ on_client_connected (GObject *source_object,
client = E_CAL_CLIENT (e_cal_client_connect_finish (result, &error));
if (error == NULL)
{
unit = (GcalManagerUnit*) g_hash_table_lookup (priv->clients,
source);
unit = g_new0 (GcalManagerUnit, 1);
unit->connected = TRUE;
unit->client = client;
/* FIXME: user should be able to disable sources */
unit->enabled = TRUE;
g_hash_table_insert (priv->clients, source, unit);
g_debug ("Source %s (%s) connected",
e_source_get_display_name (source),
e_source_get_uid (source));