Blame SOURCES/evolution-ews-3.28.5-birthday-date.patch

688341
diff -up evolution-ews-3.28.5/src/addressbook/CMakeLists.txt.birthday-date evolution-ews-3.28.5/src/addressbook/CMakeLists.txt
688341
--- evolution-ews-3.28.5/src/addressbook/CMakeLists.txt.birthday-date	2018-07-30 16:01:00.000000000 +0200
688341
+++ evolution-ews-3.28.5/src/addressbook/CMakeLists.txt	2019-10-23 14:13:13.158137514 +0200
688341
@@ -45,6 +45,7 @@ target_compile_options(ebookbackendews P
688341
 	${LIBEBOOK_CFLAGS}
688341
 	${LIBEDATABOOK_CFLAGS}
688341
 	${LIBEDATASERVER_CFLAGS}
688341
+	${LIBICAL_CFLAGS}
688341
 	${MSPACK_CFLAGS}
688341
 	${SOUP_CFLAGS}
688341
 )
688341
@@ -60,6 +61,7 @@ target_include_directories(ebookbackende
688341
 	${LIBEBOOK_INCLUDE_DIRS}
688341
 	${LIBEDATABOOK_INCLUDE_DIRS}
688341
 	${LIBEDATASERVER_INCLUDE_DIRS}
688341
+	${LIBICAL_INCLUDE_DIRS}
688341
 	${MSPACK_INCLUDE_DIRS}
688341
 	${SOUP_INCLUDE_DIRS}
688341
 )
688341
@@ -70,6 +72,7 @@ target_link_libraries(ebookbackendews
688341
 	${LIBEBOOK_LDFLAGS}
688341
 	${LIBEDATABOOK_LDFLAGS}
688341
 	${LIBEDATASERVER_LDFLAGS}
688341
+	${LIBICAL_LDFLAGS}
688341
 	${MATH_LDFLAGS}
688341
 	${MSPACK_LDFLAGS}
688341
 	${SOUP_LDFLAGS}
688341
diff -up evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c.birthday-date evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c
688341
--- evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c.birthday-date	2019-10-23 14:04:31.100144733 +0200
688341
+++ evolution-ews-3.28.5/src/addressbook/e-book-backend-ews.c	2019-10-23 14:15:41.719135459 +0200
688341
@@ -37,6 +37,8 @@
688341
 #include <glib/gstdio.h>
688341
 #include <glib/gi18n-lib.h>
688341
 
688341
+#include <libical/ical.h>
688341
+
688341
 #include <libedata-book/libedata-book.h>
688341
 
688341
 #include "server/e-ews-item-change.h"
688341
@@ -268,29 +270,36 @@ ebews_populate_nick_name (EBookBackendEw
688341
 }
688341
 
688341
 static void
688341
+ebews_populate_date_value (EBookBackendEws *bbews,
688341
+			   EContact *contact,
688341
+			   EContactField field,
688341
+			   time_t value)
688341
+{
688341
+	if (value > (time_t) 0) {
688341
+		struct icaltimetype itt;
688341
+
688341
+		itt = icaltime_from_timet_with_zone (value, TRUE, icaltimezone_get_utc_timezone ());
688341
+
688341
+		if (icaltime_is_valid_time (itt) && !icaltime_is_null_time (itt)) {
688341
+			EContactDate edate = { 0 };
688341
+
688341
+			edate.year = itt.year;
688341
+			edate.month = itt.month;
688341
+			edate.day = itt.day;
688341
+
688341
+			e_contact_set (contact, field, &edate);
688341
+		}
688341
+	}
688341
+}
688341
+
688341
+static void
688341
 ebews_populate_birth_date (EBookBackendEws *bbews,
688341
 			   EContact *contact,
688341
 			   EEwsItem *item,
688341
 			   GCancellable *cancellable,
688341
 			   GError **error)
688341
 {
688341
-	time_t bdate;
688341
-	GDate date;
688341
-	EContactDate edate;
688341
-
688341
-	bdate = e_ews_item_get_birthday (item);
688341
-
688341
-	if (bdate) {
688341
-		g_date_clear (&date, 1);
688341
-		g_date_set_time_t (&date, bdate);
688341
-
688341
-		edate.year = date.year;
688341
-		edate.month = date.month;
688341
-		edate.day = date.day;
688341
-
688341
-		if (g_date_valid (&date))
688341
-			e_contact_set (contact, E_CONTACT_BIRTH_DATE, &edate);
688341
-	}
688341
+	ebews_populate_date_value (bbews, contact, E_CONTACT_BIRTH_DATE, e_ews_item_get_birthday (item));
688341
 }
688341
 
688341
 static void
688341
@@ -300,23 +309,7 @@ ebews_populate_anniversary (EBookBackend
688341
 			    GCancellable *cancellable,
688341
 			    GError **error)
688341
 {
688341
-	time_t bdate;
688341
-	GDate date;
688341
-	EContactDate edate;
688341
-
688341
-	bdate = e_ews_item_get_wedding_anniversary (item);
688341
-
688341
-	if (bdate) {
688341
-		g_date_clear (&date, 1);
688341
-		g_date_set_time_t (&date, bdate);
688341
-
688341
-		edate.year = date.year;
688341
-		edate.month = date.month;
688341
-		edate.day = date.day;
688341
-
688341
-		if (g_date_valid (&date))
688341
-			e_contact_set (contact, E_CONTACT_ANNIVERSARY, &edate);
688341
-	}
688341
+	ebews_populate_date_value (bbews, contact, E_CONTACT_ANNIVERSARY, e_ews_item_get_wedding_anniversary (item));
688341
 }
688341
 
688341
 static EContactPhoto *
688341
@@ -600,34 +593,41 @@ ebews_set_full_name (ESoapMessage *msg,
688341
 	e_contact_name_free (name);
688341
 }
688341
 
688341
-/* TODO Set birth and anniversary dates */
688341
 static void
688341
-ebews_set_birth_date (ESoapMessage *message,
688341
-                      EContact *contact)
688341
+ebews_set_date_value (ESoapMessage *message,
688341
+		      EContact *contact,
688341
+		      EContactField field,
688341
+		      const gchar *element_name)
688341
 {
688341
 	EContactDate *date;
688341
-	gchar *birthday;
688341
+	gchar *value;
688341
 
688341
-	date = e_contact_get (contact, E_CONTACT_BIRTH_DATE);
688341
+	date = e_contact_get (contact, field);
688341
 
688341
 	if (!date)
688341
 		return;
688341
 
688341
-	birthday = g_strdup_printf (
688341
-		"%04d-%02d-%02dT00:00:00",
688341
+	value = g_strdup_printf ("%04d-%02d-%02dT00:00:00Z",
688341
 		date->year, date->month, date->day);
688341
 
688341
-	e_ews_message_write_string_parameter (message, "Birthday", NULL, birthday);
688341
+	e_ews_message_write_string_parameter (message, element_name, NULL, value);
688341
 
688341
-	g_free (birthday);
688341
+	e_contact_date_free (date);
688341
+	g_free (value);
688341
+}
688341
 
688341
+static void
688341
+ebews_set_birth_date (ESoapMessage *message,
688341
+                      EContact *contact)
688341
+{
688341
+	ebews_set_date_value (message, contact, E_CONTACT_BIRTH_DATE, "Birthday");
688341
 }
688341
 
688341
 static void
688341
 ebews_set_anniversary (ESoapMessage *message,
688341
                        EContact *contact)
688341
 {
688341
-
688341
+	ebews_set_date_value (message, contact, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
688341
 }
688341
 
688341
 static void
688341
@@ -838,30 +838,33 @@ ebews_set_full_name_changes (EBookBacken
688341
 }
688341
 
688341
 static void
688341
-ebews_set_birth_date_changes (EBookBackendEws *bbews,
688341
-			      ESoapMessage *message,
688341
+ebews_set_date_value_changes (ESoapMessage *message,
688341
 			      EContact *new,
688341
 			      EContact *old,
688341
-			      gchar **out_new_change_key,
688341
-			      GCancellable *cancellable,
688341
-			      GError **error)
688341
+			      EContactField field,
688341
+			      const gchar *element_name)
688341
 {
688341
 	EContactDate *new_date, *old_date;
688341
-	gchar *birthday;
688341
 
688341
 	if (!message)
688341
 		return;
688341
 
688341
-	new_date = e_contact_get (new, E_CONTACT_BIRTH_DATE);
688341
-	old_date = e_contact_get (old, E_CONTACT_BIRTH_DATE);
688341
+	new_date = e_contact_get (new, field);
688341
+	old_date = e_contact_get (old, field);
688341
 
688341
 	if (!e_contact_date_equal (new_date, old_date)) {
688341
-		birthday = g_strdup_printf (
688341
-			"%04d-%02d-%02dT00:00:00",
688341
-			new_date->year, new_date->month, new_date->day);
688341
+		if (new_date) {
688341
+			gchar *value;
688341
+
688341
+			value = g_strdup_printf ("%04d-%02d-%02dT00:00:00Z",
688341
+				new_date->year, new_date->month, new_date->day);
688341
+
688341
+			convert_contact_property_to_updatexml (message, element_name, value, "contacts", NULL, NULL);
688341
 
688341
-		convert_contact_property_to_updatexml (message, "Birthday", birthday, "contacts", NULL, NULL);
688341
-		g_free (birthday);
688341
+			g_free (value);
688341
+		} else {
688341
+			e_ews_message_add_delete_item_field (message, element_name, "contacts");
688341
+		}
688341
 	}
688341
 
688341
 	e_contact_date_free (new_date);
688341
@@ -869,6 +872,18 @@ ebews_set_birth_date_changes (EBookBacke
688341
 }
688341
 
688341
 static void
688341
+ebews_set_birth_date_changes (EBookBackendEws *bbews,
688341
+			      ESoapMessage *message,
688341
+			      EContact *new,
688341
+			      EContact *old,
688341
+			      gchar **out_new_change_key,
688341
+			      GCancellable *cancellable,
688341
+			      GError **error)
688341
+{
688341
+	ebews_set_date_value_changes (message, new, old, E_CONTACT_BIRTH_DATE, "Birthday");
688341
+}
688341
+
688341
+static void
688341
 ebews_set_anniversary_changes (EBookBackendEws *bbews,
688341
 			       ESoapMessage *message,
688341
 			       EContact *new,
688341
@@ -877,7 +892,7 @@ ebews_set_anniversary_changes (EBookBack
688341
 			       GCancellable *cancellable,
688341
 			       GError **error)
688341
 {
688341
-
688341
+	ebews_set_date_value_changes (message, new, old, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
688341
 }
688341
 
688341
 static void
688341
@@ -1373,7 +1388,7 @@ static const struct field_element_mappin
688341
 	{ E_CONTACT_SPOUSE, ELEMENT_TYPE_SIMPLE, "SpouseName", e_ews_item_get_spouse_name},
688341
 	{ E_CONTACT_FAMILY_NAME, ELEMENT_TYPE_SIMPLE, "Surname", e_ews_item_get_surname},
688341
 	{ E_CONTACT_GIVEN_NAME, ELEMENT_TYPE_COMPLEX, "GivenName", NULL, ebews_populate_givenname, ebews_set_givenname, ebews_set_givenname_changes},
688341
-	{ E_CONTACT_BIRTH_DATE, ELEMENT_TYPE_COMPLEX, "WeddingAnniversary", NULL,  ebews_populate_anniversary, ebews_set_anniversary, ebews_set_anniversary_changes },
688341
+	{ E_CONTACT_ANNIVERSARY, ELEMENT_TYPE_COMPLEX, "WeddingAnniversary", NULL,  ebews_populate_anniversary, ebews_set_anniversary, ebews_set_anniversary_changes },
688341
 	{ E_CONTACT_PHOTO, ELEMENT_TYPE_COMPLEX, "Photo", NULL,  ebews_populate_photo, ebews_set_photo, ebews_set_photo_changes },
688341
 
688341
 	/* Should take of uid and changekey (REV) */
688341
@@ -3515,6 +3530,7 @@ ebb_ews_get_backend_property (EBookBacke
688341
 			e_contact_field_name (E_CONTACT_ADDRESS_WORK),
688341
 			e_contact_field_name (E_CONTACT_ADDRESS_HOME),
688341
 			e_contact_field_name (E_CONTACT_ADDRESS_OTHER),
688341
+			e_contact_field_name (E_CONTACT_ANNIVERSARY),
688341
 			e_contact_field_name (E_CONTACT_BIRTH_DATE),
688341
 			e_contact_field_name (E_CONTACT_NOTE),
688341
 			e_contact_field_name (E_CONTACT_PHOTO),