[evolution-ews/gnome-40] I#155 - Contacts: Birthday/Anniversary before Epoch ignored
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-40] I#155 - Contacts: Birthday/Anniversary before Epoch ignored
- Date: Mon, 21 Jun 2021 10:53:00 +0000 (UTC)
commit b14f73991085e8e294a4e39d9278a66796574366
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 21 12:50:51 2021 +0200
I#155 - Contacts: Birthday/Anniversary before Epoch ignored
Closes https://gitlab.gnome.org/GNOME/evolution-ews/-/issues/155
src/EWS/addressbook/e-book-backend-ews.c | 14 +++++---
src/EWS/common/e-ews-item.c | 16 +++++++--
src/EWS/common/e-ews-item.h | 6 ++--
src/Microsoft365/addressbook/e-book-backend-m365.c | 5 +--
src/Microsoft365/common/e-m365-json-utils.c | 41 +++++++++++++---------
src/Microsoft365/common/e-m365-json-utils.h | 6 ++--
6 files changed, 59 insertions(+), 29 deletions(-)
---
diff --git a/src/EWS/addressbook/e-book-backend-ews.c b/src/EWS/addressbook/e-book-backend-ews.c
index a72ed5b1..2a06a348 100644
--- a/src/EWS/addressbook/e-book-backend-ews.c
+++ b/src/EWS/addressbook/e-book-backend-ews.c
@@ -409,9 +409,15 @@ static void
ebews_populate_date_value (EBookBackendEws *bbews,
EContact *contact,
EContactField field,
- time_t value)
+ EEwsItem *item,
+ time_t (*get_func) (EEwsItem *item, gboolean *out_exists))
{
- if (value > (time_t) 0) {
+ time_t value;
+ gboolean exists = FALSE;
+
+ value = get_func (item, &exists);
+
+ if (exists) {
ICalTime *itt;
itt = i_cal_time_new_from_timet_with_zone (value, TRUE, i_cal_timezone_get_utc_timezone ());
@@ -437,7 +443,7 @@ ebews_populate_birth_date (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_populate_date_value (bbews, contact, E_CONTACT_BIRTH_DATE, e_ews_item_get_birthday (item));
+ ebews_populate_date_value (bbews, contact, E_CONTACT_BIRTH_DATE, item, e_ews_item_get_birthday);
}
static void
@@ -447,7 +453,7 @@ ebews_populate_anniversary (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_populate_date_value (bbews, contact, E_CONTACT_ANNIVERSARY, e_ews_item_get_wedding_anniversary
(item));
+ ebews_populate_date_value (bbews, contact, E_CONTACT_ANNIVERSARY, item,
e_ews_item_get_wedding_anniversary);
}
static EContactPhoto *
diff --git a/src/EWS/common/e-ews-item.c b/src/EWS/common/e-ews-item.c
index 9484a9a7..768a3891 100644
--- a/src/EWS/common/e-ews-item.c
+++ b/src/EWS/common/e-ews-item.c
@@ -40,7 +40,9 @@ struct _EEwsContactFields {
gchar *business_homepage;
+ gboolean has_birthday;
time_t birthday;
+ gboolean has_wedding_anniversary;
time_t wedding_anniversary;
gchar *profession;
@@ -792,6 +794,7 @@ parse_contact_field (EEwsItem *item,
} else if (!g_ascii_strcasecmp (name, "AssistantName")) {
priv->contact_fields->assistant_name = e_soap_parameter_get_string_value (subparam);
} else if (!g_ascii_strcasecmp (name, "Birthday")) {
+ priv->contact_fields->has_birthday = TRUE;
priv->contact_fields->birthday = ews_item_parse_date (subparam);
} else if (!g_ascii_strcasecmp (name, "BusinessHomePage")) {
priv->contact_fields->business_homepage = e_soap_parameter_get_string_value (subparam);
@@ -817,6 +820,7 @@ parse_contact_field (EEwsItem *item,
} else if (!g_ascii_strcasecmp (name, "MiddleName")) {
priv->contact_fields->middlename = e_soap_parameter_get_string_value (subparam);
} else if (!g_ascii_strcasecmp (name, "WeddingAnniversary")) {
+ priv->contact_fields->has_wedding_anniversary = TRUE;
priv->contact_fields->wedding_anniversary = ews_item_parse_date (subparam);
} else if (!g_ascii_strcasecmp (name, "Body")) {
/*
@@ -2697,20 +2701,28 @@ e_ews_item_get_notes (EEwsItem *item)
}
time_t
-e_ews_item_get_birthday (EEwsItem *item)
+e_ews_item_get_birthday (EEwsItem *item,
+ gboolean *out_exists)
{
g_return_val_if_fail (E_IS_EWS_ITEM (item), -1);
g_return_val_if_fail (item->priv->contact_fields != NULL, -1);
+ if (out_exists)
+ *out_exists = item->priv->contact_fields->has_birthday;
+
return item->priv->contact_fields->birthday;
}
time_t
-e_ews_item_get_wedding_anniversary (EEwsItem *item)
+e_ews_item_get_wedding_anniversary (EEwsItem *item,
+ gboolean *out_exists)
{
g_return_val_if_fail (E_IS_EWS_ITEM (item), -1);
g_return_val_if_fail (item->priv->contact_fields != NULL, -1);
+ if (out_exists)
+ *out_exists = item->priv->contact_fields->has_wedding_anniversary;
+
return item->priv->contact_fields->wedding_anniversary;
}
diff --git a/src/EWS/common/e-ews-item.h b/src/EWS/common/e-ews-item.h
index fde46528..90753fd9 100644
--- a/src/EWS/common/e-ews-item.h
+++ b/src/EWS/common/e-ews-item.h
@@ -409,9 +409,11 @@ const gchar * e_ews_item_get_manager (EEwsItem *item);
const gchar * e_ews_item_get_office_location (EEwsItem *item);
const gchar * e_ews_item_get_business_homepage
(EEwsItem *item);
-time_t e_ews_item_get_birthday (EEwsItem *item);
+time_t e_ews_item_get_birthday (EEwsItem *item,
+ gboolean *out_exists);
time_t e_ews_item_get_wedding_anniversary
- (EEwsItem *item);
+ (EEwsItem *item,
+ gboolean *out_exists);
const gchar * e_ews_item_get_profession (EEwsItem *item);
const gchar * e_ews_item_get_spouse_name (EEwsItem *item);
const gchar * e_ews_item_get_culture (EEwsItem *item);
diff --git a/src/Microsoft365/addressbook/e-book-backend-m365.c
b/src/Microsoft365/addressbook/e-book-backend-m365.c
index bfe19958..79fede80 100644
--- a/src/Microsoft365/addressbook/e-book-backend-m365.c
+++ b/src/Microsoft365/addressbook/e-book-backend-m365.c
@@ -107,10 +107,11 @@ ebb_m365_contact_get_birthday (EBookBackendM365 *bbm365,
GError **error)
{
time_t value;
+ gboolean exists = FALSE;
- value = e_m365_contact_get_birthday (m365_contact);
+ value = e_m365_contact_get_birthday (m365_contact, &exists);
- if (value > (time_t) 0) {
+ if (exists) {
EContactDate dt;
struct tm stm;
diff --git a/src/Microsoft365/common/e-m365-json-utils.c b/src/Microsoft365/common/e-m365-json-utils.c
index 9427331d..9af7659b 100644
--- a/src/Microsoft365/common/e-m365-json-utils.c
+++ b/src/Microsoft365/common/e-m365-json-utils.c
@@ -701,9 +701,11 @@ e_m365_time_of_day_encode (gint hour,
time_t
e_m365_get_date_time_offset_member (JsonObject *object,
- const gchar *member_name)
+ const gchar *member_name,
+ gboolean *out_exists)
{
const gchar *value;
+ gboolean exists = FALSE;
time_t res = (time_t) 0;
value = e_m365_json_get_string_member (object, member_name, NULL);
@@ -730,10 +732,14 @@ e_m365_get_date_time_offset_member (JsonObject *object,
if (dt) {
res = (time_t) g_date_time_to_unix (dt);
+ exists = TRUE;
g_date_time_unref (dt);
}
}
+ if (out_exists)
+ *out_exists = exists;
+
return res;
}
@@ -784,7 +790,7 @@ e_m365_add_date_time_offset_member (JsonBuilder *builder,
time_t
e_m365_date_time_get_date_time (EM365DateTimeWithZone *datetime)
{
- return e_m365_get_date_time_offset_member (datetime, "dateTime");
+ return e_m365_get_date_time_offset_member (datetime, "dateTime", NULL);
}
const gchar *
@@ -1216,7 +1222,7 @@ e_m365_mail_message_get_conversation_index (EM365MailMessage *mail)
time_t
e_m365_mail_message_get_created_date_time (EM365MailMessage *mail)
{
- return e_m365_get_date_time_offset_member (mail, "createdDateTime");
+ return e_m365_get_date_time_offset_member (mail, "createdDateTime", NULL);
}
EM365FollowupFlag *
@@ -1370,7 +1376,7 @@ e_m365_mail_message_add_is_read_receipt_requested (JsonBuilder *builder,
time_t
e_m365_mail_message_get_last_modified_date_time (EM365MailMessage *mail)
{
- return e_m365_get_date_time_offset_member (mail, "lastModifiedDateTime");
+ return e_m365_get_date_time_offset_member (mail, "lastModifiedDateTime", NULL);
}
const gchar *
@@ -1382,7 +1388,7 @@ e_m365_mail_message_get_parent_folder_id (EM365MailMessage *mail)
time_t
e_m365_mail_message_get_received_date_time (EM365MailMessage *mail)
{
- return e_m365_get_date_time_offset_member (mail, "receivedDateTime");
+ return e_m365_get_date_time_offset_member (mail, "receivedDateTime", NULL);
}
void
@@ -1429,7 +1435,7 @@ e_m365_mail_message_add_sender (JsonBuilder *builder,
time_t
e_m365_mail_message_get_sent_date_time (EM365MailMessage *mail)
{
- return e_m365_get_date_time_offset_member (mail, "sentDateTime");
+ return e_m365_get_date_time_offset_member (mail, "sentDateTime", NULL);
}
void
@@ -1546,7 +1552,7 @@ e_m365_attachment_add_is_inline (JsonBuilder *builder,
time_t
e_m365_attachment_get_last_modified_date_time (EM365Attachment *attachment)
{
- return e_m365_get_date_time_offset_member (attachment, "lastModifiedDateTime");
+ return e_m365_get_date_time_offset_member (attachment, "lastModifiedDateTime", NULL);
}
void
@@ -1722,13 +1728,13 @@ e_m365_contact_get_change_key (EM365Contact *contact)
time_t
e_m365_contact_get_created_date_time (EM365Contact *contact)
{
- return e_m365_get_date_time_offset_member (contact, "createdDateTime");
+ return e_m365_get_date_time_offset_member (contact, "createdDateTime", NULL);
}
time_t
e_m365_contact_get_last_modified_date_time (EM365Contact *contact)
{
- return e_m365_get_date_time_offset_member (contact, "lastModifiedDateTime");
+ return e_m365_get_date_time_offset_member (contact, "lastModifiedDateTime", NULL);
}
const gchar *
@@ -1745,9 +1751,10 @@ e_m365_contact_add_assistant_name (JsonBuilder *builder,
}
time_t
-e_m365_contact_get_birthday (EM365Contact *contact)
+e_m365_contact_get_birthday (EM365Contact *contact,
+ gboolean *out_exists)
{
- return e_m365_get_date_time_offset_member (contact, "birthday");
+ return e_m365_get_date_time_offset_member (contact, "birthday", out_exists);
}
void
@@ -2463,7 +2470,7 @@ e_m365_response_status_get_response (EM365ResponseStatus *response_status)
time_t
e_m365_response_status_get_time (EM365ResponseStatus *response_status)
{
- return e_m365_get_date_time_offset_member (response_status, "time");
+ return e_m365_get_date_time_offset_member (response_status, "time", NULL);
}
/* https://docs.microsoft.com/en-us/graph/api/resources/attendee?view=graph-rest-1.0 */
@@ -3066,7 +3073,7 @@ e_m365_event_add_category (JsonBuilder *builder,
time_t
e_m365_event_get_created_date_time (EM365Event *event)
{
- return e_m365_get_date_time_offset_member (event, "createdDateTime");
+ return e_m365_get_date_time_offset_member (event, "createdDateTime", NULL);
}
EM365DateTimeWithZone *
@@ -3168,7 +3175,7 @@ e_m365_event_add_is_reminder_on (JsonBuilder *builder,
time_t
e_m365_event_get_last_modified_date_time (EM365Event *event)
{
- return e_m365_get_date_time_offset_member (event, "lastModifiedDateTime");
+ return e_m365_get_date_time_offset_member (event, "lastModifiedDateTime", NULL);
}
EM365Location *
@@ -3289,7 +3296,7 @@ e_m365_event_get_original_end_timezone (EM365Event *event)
time_t
e_m365_event_get_original_start (EM365Event *event)
{
- return e_m365_get_date_time_offset_member (event, "originalStart");
+ return e_m365_get_date_time_offset_member (event, "originalStart", NULL);
}
const gchar *
@@ -3711,7 +3718,7 @@ e_m365_task_add_completed_date_time (JsonBuilder *builder,
time_t
e_m365_task_get_created_date_time (EM365Task *task)
{
- return e_m365_get_date_time_offset_member (task, "createdDateTime");
+ return e_m365_get_date_time_offset_member (task, "createdDateTime", NULL);
}
EM365DateTimeWithZone *
@@ -3769,7 +3776,7 @@ e_m365_task_add_is_reminder_on (JsonBuilder *builder,
time_t
e_m365_task_get_last_modified_date_time (EM365Task *task)
{
- return e_m365_get_date_time_offset_member (task, "lastModifiedDateTime");
+ return e_m365_get_date_time_offset_member (task, "lastModifiedDateTime", NULL);
}
const gchar *
diff --git a/src/Microsoft365/common/e-m365-json-utils.h b/src/Microsoft365/common/e-m365-json-utils.h
index df5a0548..3f99996e 100644
--- a/src/Microsoft365/common/e-m365-json-utils.h
+++ b/src/Microsoft365/common/e-m365-json-utils.h
@@ -317,7 +317,8 @@ EM365TimeOfDay e_m365_time_of_day_encode (gint hour,
gint fraction);
time_t e_m365_get_date_time_offset_member (JsonObject *object,
- const gchar *member_name);
+ const gchar *member_name,
+ gboolean *out_exists);
void e_m365_add_date_time_offset_member (JsonBuilder *builder,
const gchar *member_name,
time_t value);
@@ -538,7 +539,8 @@ time_t e_m365_contact_get_last_modified_date_time
const gchar * e_m365_contact_get_assistant_name (EM365Contact *contact);
void e_m365_contact_add_assistant_name (JsonBuilder *builder,
const gchar *value);
-time_t e_m365_contact_get_birthday (EM365Contact *contact);
+time_t e_m365_contact_get_birthday (EM365Contact *contact,
+ gboolean *out_exists);
void e_m365_contact_add_birthday (JsonBuilder *builder,
time_t value);
EM365PhysicalAddress *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]