Unref source. (fetch_corba_cal): Ref and keep source. (e_cal_get_source):
authorHans Petter Jansson <hpj@ximian.com>
Thu, 18 Dec 2003 02:13:55 +0000 (02:13 +0000)
committerHans Petter <hansp@src.gnome.org>
Thu, 18 Dec 2003 02:13:55 +0000 (02:13 +0000)
2003-12-17  Hans Petter Jansson  <hpj@ximian.com>

* libecal/e-cal.c (e_cal_finalize): Unref source.
(fetch_corba_cal): Ref and keep source.
(e_cal_get_source): Implement.

calendar/libecal/e-cal.c
calendar/libecal/e-cal.h

index 0423369..fa9e305 100644 (file)
@@ -61,6 +61,7 @@ struct _ECalPrivate {
        /* URI of the calendar that is being loaded or is already loaded, or
         * NULL if we are not loaded.
         */
+       ESource *source;
        char *uri;
        CalObjType type;
        
@@ -1051,6 +1052,11 @@ e_cal_finalize (GObject *object)
 
        priv->load_state = E_CAL_LOAD_NOT_LOADED;
 
+       if (priv->source) {
+               g_object_unref (priv->source);
+               priv->source = NULL;
+       }
+
        if (priv->uri) {
                g_free (priv->uri);
                priv->uri = NULL;
@@ -1216,6 +1222,9 @@ fetch_corba_cal (ECal *ecal, ESource *source, CalObjType type)
                return FALSE;
        }
 
+       g_object_ref (source);
+       priv->source = source;
+
        priv->uri = g_strdup (str_uri);
        priv->type = type;
 
@@ -1584,6 +1593,27 @@ e_cal_get_load_state (ECal *ecal)
 }
 
 /**
+ * e_cal_get_source:
+ * @ecal: A calendar ecal.
+ * 
+ * Queries the source that is open in a calendar ecal.
+ * 
+ * Return value: The source of the calendar that is already loaded or is being
+ * loaded, or NULL if the ecal has not started a load request yet.
+ **/
+ESource *
+e_cal_get_source (ECal *ecal)
+{
+       ECalPrivate *priv;
+
+       g_return_val_if_fail (ecal != NULL, NULL);
+       g_return_val_if_fail (E_IS_CAL (ecal), NULL);
+
+       priv = ecal->priv;
+       return priv->source;
+}
+
+/**
  * e_cal_get_uri:
  * @ecal: A calendar ecal.
  * 
index 17682b9..6301079 100644 (file)
@@ -107,6 +107,7 @@ GList *e_cal_uri_list (ECal *ecal, CalMode mode);
 
 ECalLoadState e_cal_get_load_state (ECal *ecal);
 
+ESource *e_cal_get_source (ECal *ecal);
 const char *e_cal_get_uri (ECal *ecal);
 
 gboolean e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error);