Michael Catanzaro 101d50c
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
Michael Catanzaro 101d50c
index 54131aa8..bca45d8f 100644
Michael Catanzaro 101d50c
--- a/src/gcal-manager.c
Michael Catanzaro 101d50c
+++ b/src/gcal-manager.c
Michael Catanzaro 101d50c
@@ -345,7 +345,7 @@ on_client_connected (GObject      *source_object,
Michael Catanzaro 101d50c
   ESourceRefresh *refresh_extension;
Michael Catanzaro 101d50c
   ESourceOffline *offline_extension;
Michael Catanzaro 101d50c
   GcalManager *self;
Michael Catanzaro 101d50c
-  ECalClient *client;
Michael Catanzaro 101d50c
+  EClient *client;
Michael Catanzaro 101d50c
   ESource *source;
Michael Catanzaro 101d50c
   GError *error;
Michael Catanzaro 101d50c
   gboolean enabled;
Michael Catanzaro 101d50c
@@ -353,8 +353,6 @@ on_client_connected (GObject      *source_object,
Michael Catanzaro 101d50c
   GCAL_ENTRY;
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   self = GCAL_MANAGER (user_data);
Michael Catanzaro 101d50c
-  source = e_client_get_source (E_CLIENT (source_object));
Michael Catanzaro 101d50c
-  enabled = is_source_enabled (source);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   self->sources_at_launch--;
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
@@ -362,28 +360,28 @@ on_client_connected (GObject      *source_object,
Michael Catanzaro 101d50c
     g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LOADING]);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   error = NULL;
Michael Catanzaro 101d50c
-  client = E_CAL_CLIENT (e_cal_client_connect_finish (result, &error));
Michael Catanzaro 101d50c
+  client = e_cal_client_connect_finish (result, &error);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   if (error)
Michael Catanzaro 101d50c
     {
Michael Catanzaro 101d50c
-      remove_source (GCAL_MANAGER (user_data), source);
Michael Catanzaro 101d50c
-      g_warning ("%s: Failed to open/connect '%s': %s",
Michael Catanzaro 101d50c
+      g_warning ("%s: Failed to open/connect calendar: %s",
Michael Catanzaro 101d50c
                  G_STRFUNC,
Michael Catanzaro 101d50c
-                 e_source_get_display_name (source),
Michael Catanzaro 101d50c
                  error->message);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
-      g_object_unref (source);
Michael Catanzaro 101d50c
       g_error_free (error);
Michael Catanzaro 101d50c
       return;
Michael Catanzaro 101d50c
     }
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
+  source = e_client_get_source (client);
Michael Catanzaro 101d50c
+  enabled = is_source_enabled (source);
Michael Catanzaro 101d50c
+
Michael Catanzaro 101d50c
   g_object_set_data (G_OBJECT (source), "client", client);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   unit = g_new0 (GcalManagerUnit, 1);
Michael Catanzaro 101d50c
   unit->connected = TRUE;
Michael Catanzaro 101d50c
-  unit->client = g_object_ref (client);
Michael Catanzaro 101d50c
+  unit->client = g_object_ref (E_CAL_CLIENT (client));
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
-  g_hash_table_insert (self->clients, source, unit);
Michael Catanzaro 101d50c
+  g_hash_table_insert (self->clients, g_object_ref (source), unit);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   g_debug ("Source %s (%s) connected",
Michael Catanzaro 101d50c
            e_source_get_display_name (source),
Michael Catanzaro 101d50c
@@ -394,15 +392,17 @@ on_client_connected (GObject      *source_object,
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   if (enabled)
Michael Catanzaro 101d50c
     {
Michael Catanzaro 101d50c
-      e_cal_data_model_add_client (self->e_data_model, client);
Michael Catanzaro 101d50c
-      e_cal_data_model_add_client (self->search_data_model, client);
Michael Catanzaro 101d50c
+      ECalClient *cal_client = E_CAL_CLIENT (client);
Michael Catanzaro 101d50c
+
Michael Catanzaro 101d50c
+      e_cal_data_model_add_client (self->e_data_model, cal_client);
Michael Catanzaro 101d50c
+      e_cal_data_model_add_client (self->search_data_model, cal_client);
Michael Catanzaro 101d50c
       if (self->shell_search_data_model != NULL)
Michael Catanzaro 101d50c
-        e_cal_data_model_add_client (self->shell_search_data_model, client);
Michael Catanzaro 101d50c
+        e_cal_data_model_add_client (self->shell_search_data_model, cal_client);
Michael Catanzaro 101d50c
     }
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   /* refresh client when it's added */
Michael Catanzaro 101d50c
-  if (enabled && e_client_check_refresh_supported (E_CLIENT (client)))
Michael Catanzaro 101d50c
-    e_client_refresh (E_CLIENT (client), NULL, on_client_refreshed, user_data);
Michael Catanzaro 101d50c
+  if (enabled && e_client_check_refresh_supported (client))
Michael Catanzaro 101d50c
+    e_client_refresh (client, NULL, on_client_refreshed, user_data);
Michael Catanzaro 101d50c
 
Michael Catanzaro 101d50c
   /* Cache all the online calendars, so the user can see them offline */
Michael Catanzaro 101d50c
   offline_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_OFFLINE);