[evolution-data-server] Let EDataCal track the "opened" state.



commit ff4f733418598d4d82b1c02fb3d5efcb5a427ef1
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Mar 21 13:29:32 2013 -0400

    Let EDataCal track the "opened" state.
    
    Due to the asymmetric nature of our backend APIs, the open() method
    begins in ECalBackend, but the end result is reported to EDataCal.
    So it makes more sense for EDataCal to track the backend's "opened"
    state, at least until the APIs can be modernized.
    
    This adds a new function -- e_data_cal_is_opened() -- which is just a
    temporary hack and should only be called by e_cal_backend_is_opened().
    
    This avoids EDataCal needing to call e_cal_backend_notify_opened(),
    which is deprecated and about to be removed.

 calendar/libedata-cal/e-cal-backend.c              |   20 ++++++----
 calendar/libedata-cal/e-data-cal.c                 |   36 ++++++++++++++++----
 calendar/libedata-cal/e-data-cal.h                 |    1 +
 .../libedata-cal/libedata-cal-sections.txt         |    1 +
 4 files changed, 43 insertions(+), 15 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 5c9496a..b42cd38 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -46,7 +46,7 @@ struct _ECalBackendPrivate {
        /* The kind of components for this backend */
        icalcomponent_kind kind;
 
-       gboolean opened, removed;
+       gboolean removed;
        gboolean writable;
 
        gchar *cache_dir;
@@ -802,9 +802,19 @@ e_cal_backend_set_writable (ECalBackend *backend,
 gboolean
 e_cal_backend_is_opened (ECalBackend *backend)
 {
+       EDataCal *data_cal;
+       gboolean opened = FALSE;
+
        g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
 
-       return backend->priv->opened;
+       data_cal = e_cal_backend_ref_data_cal (backend);
+
+       if (data_cal != NULL) {
+               opened = e_data_cal_is_opened (data_cal);
+               g_object_unref (data_cal);
+       }
+
+       return opened;
 }
 
 /**
@@ -1984,12 +1994,6 @@ void
 e_cal_backend_notify_opened (ECalBackend *backend,
                              GError *error)
 {
-       g_return_if_fail (E_IS_CAL_BACKEND (backend));
-
-       backend->priv->opened = (error == NULL);
-
-       if (error != NULL)
-               g_error_free (error);
 }
 
 /**
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index 681e760..cec35c6 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -52,6 +52,8 @@ struct _EDataCalPrivate {
        GWeakRef backend;
        gchar *object_path;
 
+       gboolean opened;
+
        GRecMutex pending_ops_lock;
        GHashTable *pending_ops; /* opid -> OperationData */
 
@@ -1335,7 +1337,6 @@ e_data_cal_respond_open (EDataCal *cal,
                          GError *error)
 {
        OperationData *data;
-       GError *copy = NULL;
 
        g_return_if_fail (E_IS_DATA_CAL (cal));
 
@@ -1345,12 +1346,7 @@ e_data_cal_respond_open (EDataCal *cal,
        /* Translators: This is prefix to a detailed error message */
        g_prefix_error (&error, "%s", _("Cannot open calendar: "));
 
-       /* This function is deprecated, but it's the only way to
-        * set ECalBackend's internal 'opened' flag.  We should
-        * be the only ones calling this. */
-       if (error != NULL)
-               copy = g_error_copy (error);
-       e_cal_backend_notify_opened (data->backend, copy);
+       cal->priv->opened = (error == NULL);
 
        if (error == NULL) {
                e_dbus_calendar_complete_open (
@@ -2756,3 +2752,29 @@ e_data_cal_get_object_path (EDataCal *cal)
        return cal->priv->object_path;
 }
 
+/**
+ * e_data_cal_is_opened:
+ * @cal: an #EDataCal
+ *
+ * Returns whether the @cal's #EDataCal:backend was successfully opened.
+ *
+ * <note>
+ *   <para>
+ *     This is a temporary function serving only to keep
+ *     e_cal_backend_is_opened() working for a little while longer.
+ *     Do not call this function directly.
+ *   </para>
+ * </note>
+ *
+ * Returns: whether the #EDataCal:backend is opened
+ *
+ * Since: 3.10
+ **/
+gboolean
+e_data_cal_is_opened (EDataCal *cal)
+{
+       g_return_val_if_fail (E_IS_DATA_CAL (cal), FALSE);
+
+       return cal->priv->opened;
+}
+
diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h
index 9c7e37a..c107f31 100644
--- a/calendar/libedata-cal/e-data-cal.h
+++ b/calendar/libedata-cal/e-data-cal.h
@@ -176,6 +176,7 @@ struct _ECalBackend *
 GDBusConnection *
                e_data_cal_get_connection       (EDataCal *cal);
 const gchar *  e_data_cal_get_object_path      (EDataCal *cal);
+gboolean       e_data_cal_is_opened            (EDataCal *cal);
 
 void           e_data_cal_respond_open         (EDataCal *cal,
                                                 guint32 opid,
diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt 
b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
index 676c27c..d97c2f0 100644
--- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
+++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
@@ -248,6 +248,7 @@ e_data_cal_new
 e_data_cal_ref_backend
 e_data_cal_get_connection
 e_data_cal_get_object_path
+e_data_cal_is_opened
 e_data_cal_respond_open
 e_data_cal_respond_refresh
 e_data_cal_respond_get_backend_property


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]