[evolution-data-server] I#43 - [CalDAV] Change of calendar-auto-schedule not used immediately



commit f5cbfdb9b63405235486343b09d75fb3d940d115
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 10 21:34:19 2018 +0200

    I#43 - [CalDAV] Change of calendar-auto-schedule not used immediately
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/43

 src/addressbook/libedata-book/e-book-backend.c     |  6 +--
 .../backends/caldav/e-cal-backend-caldav.c         | 51 +++++++++++++++++++---
 src/calendar/libedata-cal/e-cal-backend.c          |  6 +--
 3 files changed, 50 insertions(+), 13 deletions(-)
---
diff --git a/src/addressbook/libedata-book/e-book-backend.c b/src/addressbook/libedata-book/e-book-backend.c
index 44143baa7..210e07faf 100644
--- a/src/addressbook/libedata-book/e-book-backend.c
+++ b/src/addressbook/libedata-book/e-book-backend.c
@@ -3579,7 +3579,7 @@ e_book_backend_notify_error (EBookBackend *backend,
  * e_book_backend_notify_property_changed:
  * @backend: an #EBookBackend
  * @prop_name: property name, which changed
- * @prop_value: new property value
+ * @prop_value: (nullable): new property value
  *
  * Notifies clients about property value change.
  *
@@ -3594,13 +3594,11 @@ e_book_backend_notify_property_changed (EBookBackend *backend,
 
        g_return_if_fail (E_IS_BOOK_BACKEND (backend));
        g_return_if_fail (prop_name != NULL);
-       g_return_if_fail (prop_value != NULL);
 
        data_book = e_book_backend_ref_data_book (backend);
 
        if (data_book != NULL) {
-               e_data_book_report_backend_property_changed (
-                       data_book, prop_name, prop_value);
+               e_data_book_report_backend_property_changed (data_book, prop_name, prop_value ? prop_value : 
"");
                g_object_unref (data_book);
        }
 }
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c 
b/src/calendar/backends/caldav/e-cal-backend-caldav.c
index e3878f0db..c6b98f7d5 100644
--- a/src/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -2022,11 +2022,11 @@ ecb_caldav_get_backend_property (ECalBackend *backend,
        g_return_val_if_fail (prop_name != NULL, NULL);
 
        if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
+               ECalBackendCalDAV *cbdav = E_CAL_BACKEND_CALDAV (backend);
                ESourceWebdav *extension;
                ESource *source;
                GString *caps;
                gchar *usermail;
-               const gchar *extension_name;
 
                caps = g_string_new (
                        CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
@@ -2036,15 +2036,13 @@ ecb_caldav_get_backend_property (ECalBackend *backend,
                g_string_append (caps, ",");
                g_string_append (caps, e_cal_meta_backend_get_capabilities (E_CAL_META_BACKEND (backend)));
 
-               usermail = ecb_caldav_get_usermail (E_CAL_BACKEND_CALDAV (backend));
+               usermail = ecb_caldav_get_usermail (cbdav);
                if (!usermail || !*usermail)
                        g_string_append (caps, "," CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS);
                g_free (usermail);
 
                source = e_backend_get_source (E_BACKEND (backend));
-
-               extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
-               extension = e_source_get_extension (source, extension_name);
+               extension = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
 
                if (e_source_webdav_get_calendar_auto_schedule (extension)) {
                        g_string_append (
@@ -2063,6 +2061,38 @@ ecb_caldav_get_backend_property (ECalBackend *backend,
        return E_CAL_BACKEND_CLASS (e_cal_backend_caldav_parent_class)->get_backend_property (backend, 
prop_name);
 }
 
+static void
+ecb_caldav_notify_property_changed_cb (GObject *object,
+                                      GParamSpec *param,
+                                      gpointer user_data)
+{
+       ECalBackendCalDAV *cbdav = user_data;
+       ECalBackend *cal_backend;
+       gboolean email_address_changed;
+       gboolean calendar_auto_schedule_changed;
+       gchar *value;
+
+       g_return_if_fail (E_IS_CAL_BACKEND_CALDAV (cbdav));
+
+       cal_backend = E_CAL_BACKEND (cbdav);
+
+       email_address_changed = param && g_strcmp0 (param->name, "email-address") == 0;
+       calendar_auto_schedule_changed = param && g_strcmp0 (param->name, "calendar-auto-schedule") == 0;
+
+       if (email_address_changed || calendar_auto_schedule_changed) {
+               value = ecb_caldav_get_backend_property (cal_backend, CLIENT_BACKEND_PROPERTY_CAPABILITIES);
+               e_cal_backend_notify_property_changed (cal_backend, CLIENT_BACKEND_PROPERTY_CAPABILITIES, 
value);
+               g_free (value);
+       }
+
+       if (email_address_changed) {
+               value = ecb_caldav_get_backend_property (cal_backend, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS);
+               e_cal_backend_notify_property_changed (cal_backend, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, 
value);
+               e_cal_backend_notify_property_changed (cal_backend, CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS, 
value);
+               g_free (value);
+       }
+}
+
 static gchar *
 ecb_caldav_dup_component_revision_cb (ECalCache *cal_cache,
                                      icalcomponent *icalcomp)
@@ -2077,6 +2107,8 @@ e_cal_backend_caldav_constructed (GObject *object)
 {
        ECalBackendCalDAV *cbdav = E_CAL_BACKEND_CALDAV (object);
        ECalCache *cal_cache;
+       ESource *source;
+       ESourceWebdav *webdav_extension;
 
        /* Chain up to parent's method. */
        G_OBJECT_CLASS (e_cal_backend_caldav_parent_class)->constructed (object);
@@ -2089,6 +2121,15 @@ e_cal_backend_caldav_constructed (GObject *object)
        g_clear_object (&cal_cache);
 
        ecb_caldav_update_tweaks (cbdav);
+
+       source = e_backend_get_source (E_BACKEND (cbdav));
+       webdav_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
+
+       g_signal_connect_object (webdav_extension, "notify::calendar-auto-schedule",
+               G_CALLBACK (ecb_caldav_notify_property_changed_cb), cbdav, 0);
+
+       g_signal_connect_object (webdav_extension, "notify::email-address",
+               G_CALLBACK (ecb_caldav_notify_property_changed_cb), cbdav, 0);
 }
 
 static void
diff --git a/src/calendar/libedata-cal/e-cal-backend.c b/src/calendar/libedata-cal/e-cal-backend.c
index 3029f2dc5..8481e47a1 100644
--- a/src/calendar/libedata-cal/e-cal-backend.c
+++ b/src/calendar/libedata-cal/e-cal-backend.c
@@ -4537,7 +4537,7 @@ e_cal_backend_notify_error (ECalBackend *backend,
  * e_cal_backend_notify_property_changed:
  * @backend: an #ECalBackend
  * @prop_name: property name, which changed
- * @prop_value: new property value
+ * @prop_value: (nullable): new property value
  *
  * Notifies client about property value change.
  *
@@ -4552,13 +4552,11 @@ e_cal_backend_notify_property_changed (ECalBackend *backend,
 
        g_return_if_fail (E_IS_CAL_BACKEND (backend));
        g_return_if_fail (prop_name != NULL);
-       g_return_if_fail (prop_value != NULL);
 
        data_cal = e_cal_backend_ref_data_cal (backend);
 
        if (data_cal != NULL) {
-               e_data_cal_report_backend_property_changed (
-                       data_cal, prop_name, prop_value);
+               e_data_cal_report_backend_property_changed (data_cal, prop_name, prop_value ? prop_value : 
"");
                g_object_unref (data_cal);
        }
 }


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