[evolution-ews/wip/mcrha/office365: 46/50] Calendar: RRULE write (limited) and some fixes for RRULE read
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/wip/mcrha/office365: 46/50] Calendar: RRULE write (limited) and some fixes for RRULE read
- Date: Mon, 3 Aug 2020 15:24:09 +0000 (UTC)
commit 6d7efdcfca1b982283cd6aeccfa0a65e3d253bcc
Author: Milan Crha <mcrha redhat com>
Date: Wed Jul 29 14:28:02 2020 +0200
Calendar: RRULE write (limited) and some fixes for RRULE read
src/Microsoft365/calendar/e-cal-backend-m365.c | 451 ++++++++++++++++++++-----
1 file changed, 359 insertions(+), 92 deletions(-)
---
diff --git a/src/Microsoft365/calendar/e-cal-backend-m365.c b/src/Microsoft365/calendar/e-cal-backend-m365.c
index a34180d9..2b2cf473 100644
--- a/src/Microsoft365/calendar/e-cal-backend-m365.c
+++ b/src/Microsoft365/calendar/e-cal-backend-m365.c
@@ -219,8 +219,15 @@ ecb_m365_get_date_time_zone (ECalBackendM365 *cbm365,
tt = e_m365_date_time_get_date_time (value);
zone = e_m365_date_time_get_time_zone (value);
- /* Reads the time in UTC, just make sure it's still a true expectation */
- g_warn_if_fail (!zone || !*zone || g_strcmp0 (zone, "UTC") == 0);
+ if (zone && *zone)
+ zone = e_m365_tz_utils_get_ical_equivalent (zone);
+
+ tz = zone && *zone ? ecb_m365_get_timezone_sync (cbm365, zone) : NULL;
+
+ if (!tz)
+ tz = i_cal_timezone_get_utc_timezone ();
+
+ itt = i_cal_time_new_from_timet_with_zone (tt, e_m365_event_get_is_all_day (m365_event), tz);
tzid = e_m365_tz_utils_get_ical_equivalent (tzid);
@@ -228,7 +235,6 @@ ecb_m365_get_date_time_zone (ECalBackendM365 *cbm365,
tzid = "UTC";
tz = ecb_m365_get_timezone_sync (cbm365, tzid);
- itt = i_cal_time_new_from_timet_with_zone (tt, e_m365_event_get_is_all_day (m365_event),
i_cal_timezone_get_utc_timezone ());
if (tz && !e_m365_event_get_is_all_day (m365_event))
i_cal_time_convert_to_zone_inplace (itt, tz);
@@ -1055,6 +1061,102 @@ ecb_m365_add_attendees (ECalBackendM365 *cbm365,
g_hash_table_destroy (old_value);
}
+static void
+ecb_m365_get_importance (ECalBackendM365 *cbm365,
+ EM365Event *m365_event,
+ ICalComponent *inout_comp,
+ ICalPropertyKind prop_kind)
+{
+ EM365ImportanceType value;
+ ICalProperty *prop = NULL;
+
+ value = e_m365_event_get_importance (m365_event);
+
+ if (value == E_M365_IMPORTANCE_LOW)
+ prop = i_cal_property_new_priority (9);
+ else if (value == E_M365_IMPORTANCE_NORMAL)
+ prop = i_cal_property_new_priority (5);
+ else if (value == E_M365_IMPORTANCE_HIGH)
+ prop = i_cal_property_new_priority (1);
+
+ if (prop)
+ i_cal_component_take_property (inout_comp, prop);
+}
+
+static void
+ecb_m365_add_importance (ECalBackendM365 *cbm365,
+ ICalComponent *new_comp,
+ ICalComponent *old_comp,
+ ICalPropertyKind prop_kind,
+ JsonBuilder *builder)
+{
+ gint old_value = -1, new_value = -1;
+ ICalProperty *prop;
+
+ prop = i_cal_component_get_first_property (new_comp, prop_kind);
+
+ if (prop) {
+ new_value = i_cal_property_get_priority (prop);
+ g_clear_object (&prop);
+ }
+
+ prop = old_comp ? i_cal_component_get_first_property (old_comp, prop_kind) : NULL;
+
+ if (prop) {
+ old_value = i_cal_property_get_priority (prop);
+ g_clear_object (&prop);
+ }
+
+ if (new_value != old_value) {
+ EM365ImportanceType value = E_M365_IMPORTANCE_NOT_SET;
+
+ if (new_value >= 1 && new_value <= 4) {
+ value = E_M365_IMPORTANCE_HIGH;
+ } else if (new_value == 5) {
+ value = E_M365_IMPORTANCE_NORMAL;
+ } else if (new_value >= 6 && new_value <= 9) {
+ value = E_M365_IMPORTANCE_LOW;
+ }
+
+ e_m365_event_add_importance (builder, value);
+ }
+}
+
+static void
+ecb_m365_get_status (ECalBackendM365 *cbm365,
+ EM365Event *m365_event,
+ ICalComponent *inout_comp,
+ ICalPropertyKind prop_kind)
+{
+ ICalPropertyStatus status = I_CAL_STATUS_NONE;
+
+ if (e_m365_event_get_is_cancelled (m365_event)) {
+ status = I_CAL_STATUS_CANCELLED;
+ } else {
+ EM365ResponseStatus *response_status;
+
+ response_status = e_m365_event_get_response_status (m365_event);
+
+ if (response_status) {
+ EM365ResponseType response;
+
+ response = e_m365_response_status_get_response (response_status);
+
+ if (response == E_M365_RESPONSE_TENTATIVELY_ACCEPTED)
+ status = I_CAL_STATUS_TENTATIVE;
+ else if (response == E_M365_RESPONSE_ACCEPTED)
+ status = I_CAL_STATUS_CONFIRMED;
+ else if (response == E_M365_RESPONSE_DECLINED)
+ status = I_CAL_STATUS_CANCELLED;
+ else if (response == E_M365_RESPONSE_NOT_RESPONDED)
+ status = I_CAL_STATUS_NEEDSACTION;
+ }
+ }
+
+ if (status != I_CAL_STATUS_NONE)
+ i_cal_component_take_property (inout_comp, i_cal_property_new_status (status));
+}
+
static ICalRecurrenceWeekday
ecb_m365_day_of_week_to_ical (EM365DayOfWeekType dow)
{
@@ -1080,6 +1182,38 @@ ecb_m365_day_of_week_to_ical (EM365DayOfWeekType dow)
return I_CAL_NO_WEEKDAY;
}
+static EM365DayOfWeekType
+ecb_m365_day_of_week_from_ical (ICalRecurrenceWeekday dow)
+{
+ switch (dow) {
+ case I_CAL_SUNDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_SUNDAY;
+ break;
+ case I_CAL_MONDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_MONDAY;
+ break;
+ case I_CAL_TUESDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_TUESDAY;
+ break;
+ case I_CAL_WEDNESDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_WEDNESDAY;
+ break;
+ case I_CAL_THURSDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_THURSDAY;
+ break;
+ case I_CAL_FRIDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_FRIDAY;
+ break;
+ case I_CAL_SATURDAY_WEEKDAY:
+ return E_M365_DAY_OF_WEEK_SATURDAY;
+ break;
+ default:
+ break;
+ }
+
+ return E_M365_DAY_OF_WEEK_UNKNOWN;
+}
+
static void
ecb_m365_set_index_to_ical (ICalRecurrence *recr,
EM365WeekIndexType index)
@@ -1110,6 +1244,27 @@ ecb_m365_set_index_to_ical (ICalRecurrence *recr,
i_cal_recurrence_set_by_set_pos (recr, 0, by_pos);
}
+static void
+ecb_m365_add_index_from_ical (JsonBuilder *builder,
+ gint by_pos)
+{
+ EM365WeekIndexType index = E_M365_WEEK_INDEX_UNKNOWN;
+
+ if (by_pos == 1)
+ index = E_M365_WEEK_INDEX_FIRST;
+ else if (by_pos == 2)
+ index = E_M365_WEEK_INDEX_SECOND;
+ else if (by_pos == 3)
+ index = E_M365_WEEK_INDEX_THIRD;
+ else if (by_pos == 4)
+ index = E_M365_WEEK_INDEX_FOURTH;
+ else if (by_pos == -1)
+ index = E_M365_WEEK_INDEX_LAST;
+
+ if (index != E_M365_WEEK_INDEX_UNKNOWN)
+ e_m365_recurrence_pattern_add_index (builder, index);
+}
+
static void
ecb_m365_set_days_of_week_to_ical (ICalRecurrence *recr,
JsonArray *days_of_week)
@@ -1137,10 +1292,38 @@ ecb_m365_set_days_of_week_to_ical (ICalRecurrence *recr,
}
static void
+ecb_m365_add_days_of_week_from_ical (JsonBuilder *builder,
+ ICalRecurrence *recr)
+{
+ gint ii;
+
+ e_m365_recurrence_pattern_begin_days_of_week (builder);
+
+ for (ii = 0; ii < I_CAL_BY_DAY_SIZE; ii++) {
+ ICalRecurrenceWeekday week_day;
+ EM365DayOfWeekType m365_week_day;
+
+ week_day = i_cal_recurrence_get_by_day (recr, ii);
+
+ if (((gint) week_day) == I_CAL_RECURRENCE_ARRAY_MAX)
+ break;
+
+ m365_week_day = ecb_m365_day_of_week_from_ical (week_day);
+
+ if (m365_week_day != E_M365_DAY_OF_WEEK_UNKNOWN)
+ e_m365_recurrence_pattern_add_day_of_week (builder, m365_week_day);
+ }
+
+ e_m365_recurrence_pattern_end_days_of_week (builder);
+}
+
+static gboolean
ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
EM365Event *m365_event,
ICalComponent *inout_comp,
- ICalPropertyKind prop_kind)
+ ICalPropertyKind prop_kind,
+ GCancellable *cancellable,
+ GError **error)
{
EM365PatternedRecurrence *m365_recr;
EM365RecurrencePattern *m365_pattern;
@@ -1154,7 +1337,7 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
m365_range = m365_recr ? e_m365_patterned_recurrence_get_range (m365_recr) : NULL;
if (!m365_recr || !m365_pattern || !m365_range)
- return;
+ return TRUE;
ical_recr = i_cal_recurrence_new ();
@@ -1168,7 +1351,7 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
i_cal_recurrence_set_freq (ical_recr, I_CAL_WEEKLY_RECURRENCE);
i_cal_recurrence_set_interval (ical_recr, e_m365_recurrence_pattern_get_interval
(m365_pattern));
- week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_recr));
+ week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_pattern));
if (week_day != I_CAL_NO_WEEKDAY)
i_cal_recurrence_set_week_start (ical_recr, week_day);
@@ -1184,19 +1367,19 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
i_cal_recurrence_set_freq (ical_recr, I_CAL_MONTHLY_RECURRENCE);
i_cal_recurrence_set_interval (ical_recr, e_m365_recurrence_pattern_get_interval
(m365_pattern));
ecb_m365_set_days_of_week_to_ical (ical_recr, e_m365_recurrence_pattern_get_days_of_week
(m365_pattern));
- week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_recr));
+ week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_pattern));
if (week_day != I_CAL_NO_WEEKDAY)
i_cal_recurrence_set_week_start (ical_recr, week_day);
- ecb_m365_set_index_to_ical (ical_recr, e_m365_recurrence_pattern_get_index (m365_recr));
+ ecb_m365_set_index_to_ical (ical_recr, e_m365_recurrence_pattern_get_index (m365_pattern));
break;
case E_M365_RECURRENCE_PATTERN_ABSOLUTE_YEARLY:
i_cal_recurrence_set_freq (ical_recr, I_CAL_YEARLY_RECURRENCE);
i_cal_recurrence_set_interval (ical_recr, e_m365_recurrence_pattern_get_interval
(m365_pattern));
i_cal_recurrence_set_by_month_day (ical_recr, 0, e_m365_recurrence_pattern_get_day_of_month
(m365_pattern));
- month = e_m365_recurrence_pattern_get_month (m365_recr);
+ month = e_m365_recurrence_pattern_get_month (m365_pattern);
if (month >= 1 && month <= 12)
i_cal_recurrence_set_by_month (ical_recr, 0, month);
@@ -1205,14 +1388,14 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
i_cal_recurrence_set_freq (ical_recr, I_CAL_YEARLY_RECURRENCE);
i_cal_recurrence_set_interval (ical_recr, e_m365_recurrence_pattern_get_interval
(m365_pattern));
ecb_m365_set_days_of_week_to_ical (ical_recr, e_m365_recurrence_pattern_get_days_of_week
(m365_pattern));
- week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_recr));
+ week_day = ecb_m365_day_of_week_to_ical (e_m365_recurrence_pattern_get_first_day_of_week
(m365_pattern));
if (week_day != I_CAL_NO_WEEKDAY)
i_cal_recurrence_set_week_start (ical_recr, week_day);
- ecb_m365_set_index_to_ical (ical_recr, e_m365_recurrence_pattern_get_index (m365_recr));
+ ecb_m365_set_index_to_ical (ical_recr, e_m365_recurrence_pattern_get_index (m365_pattern));
- month = e_m365_recurrence_pattern_get_month (m365_recr);
+ month = e_m365_recurrence_pattern_get_month (m365_pattern);
if (month >= 1 && month <= 12)
i_cal_recurrence_set_by_month (ical_recr, 0, month);
@@ -1220,7 +1403,8 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
default:
g_object_unref (ical_recr);
g_warning ("%s: Unknown pattern type: %d", G_STRFUNC, e_m365_recurrence_pattern_get_type
(m365_pattern));
- return;
+ /* Ignore the error (in the code) and continue. */
+ return TRUE;
}
switch (e_m365_recurrence_range_get_type (m365_range)) {
@@ -1249,118 +1433,201 @@ ecb_m365_get_recurrence (ECalBackendM365 *cbm365,
default:
g_warning ("%s: Unknown range type: %d", G_STRFUNC, e_m365_recurrence_range_get_type
(m365_range));
g_object_unref (ical_recr);
- return;
+ /* Ignore the error (in the code) and continue. */
+ return TRUE;
}
i_cal_component_take_property (inout_comp, i_cal_property_new_rrule (ical_recr));
g_object_unref (ical_recr);
+
+ return TRUE;
}
-static void
+static gboolean
ecb_m365_add_recurrence (ECalBackendM365 *cbm365,
ICalComponent *new_comp,
ICalComponent *old_comp,
ICalPropertyKind prop_kind,
- JsonBuilder *builder)
+ const gchar *m365_id,
+ JsonBuilder *builder,
+ GCancellable *cancellable,
+ GError **error)
{
- /* TODO */
-}
+ ICalProperty *new_value, *old_value;
+ gboolean success = TRUE;
-static void
-ecb_m365_get_importance (ECalBackendM365 *cbm365,
- EM365Event *m365_event,
- ICalComponent *inout_comp,
- ICalPropertyKind prop_kind)
-{
- EM365ImportanceType value;
- ICalProperty *prop = NULL;
+ if (i_cal_component_count_properties (new_comp, prop_kind) > 1) {
+ g_propagate_error (error, EC_ERROR_EX (E_CLIENT_ERROR_NOT_SUPPORTED,
+ _("Microsoft 365 calendar cannot store more than one recurrence")));
- value = e_m365_event_get_importance (m365_event);
+ return FALSE;
+ }
- if (value == E_M365_IMPORTANCE_LOW)
- prop = i_cal_property_new_priority (9);
- else if (value == E_M365_IMPORTANCE_NORMAL)
- prop = i_cal_property_new_priority (5);
- else if (value == E_M365_IMPORTANCE_HIGH)
- prop = i_cal_property_new_priority (1);
+ if (i_cal_component_count_properties (new_comp, I_CAL_RDATE_PROPERTY) > 0 ||
+ i_cal_component_count_properties (new_comp, I_CAL_EXDATE_PROPERTY) > 0 ||
+ i_cal_component_count_properties (new_comp, I_CAL_EXRULE_PROPERTY) > 0) {
+ g_propagate_error (error, EC_ERROR_EX (E_CLIENT_ERROR_NOT_SUPPORTED,
+ _("Microsoft 365 calendar cannot store component with RDATE, EXDATE or RRULE
properties")));
- if (prop)
- i_cal_component_take_property (inout_comp, prop);
-}
+ return FALSE;
+ }
-static void
-ecb_m365_add_importance (ECalBackendM365 *cbm365,
- ICalComponent *new_comp,
- ICalComponent *old_comp,
- ICalPropertyKind prop_kind,
- JsonBuilder *builder)
-{
- gint old_value = -1, new_value = -1;
- ICalProperty *prop;
+ new_value = i_cal_component_get_first_property (new_comp, prop_kind);
+ old_value = old_comp ? i_cal_component_get_first_property (old_comp, prop_kind) : NULL;
- prop = i_cal_component_get_first_property (new_comp, prop_kind);
+ if (!new_value && !old_value)
+ return TRUE;
- if (prop) {
- new_value = i_cal_property_get_priority (prop);
- g_clear_object (&prop);
- }
+ if (new_value) {
+ ICalRecurrence *new_rrule;
+ gboolean same = FALSE;
- prop = old_comp ? i_cal_component_get_first_property (old_comp, prop_kind) : NULL;
+ new_rrule = i_cal_property_get_rrule (new_value);
- if (prop) {
- old_value = i_cal_property_get_priority (prop);
- g_clear_object (&prop);
- }
+ if (old_value && new_rrule) {
+ ICalRecurrence *old_rrule;
- if (new_value != old_value) {
- EM365ImportanceType value = E_M365_IMPORTANCE_NOT_SET;
+ old_rrule = i_cal_property_get_rrule (old_value);
- if (new_value >= 1 && new_value <= 4) {
- value = E_M365_IMPORTANCE_HIGH;
- } else if (new_value == 5) {
- value = E_M365_IMPORTANCE_NORMAL;
- } else if (new_value >= 6 && new_value <= 9) {
- value = E_M365_IMPORTANCE_LOW;
+ if (old_rrule) {
+ gchar *new_str, *old_str;
+
+ new_str = i_cal_recurrence_to_string (new_rrule);
+ old_str = i_cal_recurrence_to_string (old_rrule);
+
+ same = g_strcmp0 (new_str, old_str) == 0;
+
+ g_free (new_str);
+ g_free (old_str);
+ }
+
+ g_clear_object (&old_rrule);
}
- e_m365_event_add_importance (builder, value);
- }
-}
+ if (!same && new_rrule) {
+ EM365DayOfWeekType week_day;
+ ICalTime *dtstart;
+ gint by_pos, month, yy = 0, mm = 0, dd = 0;
-static void
-ecb_m365_get_status (ECalBackendM365 *cbm365,
- EM365Event *m365_event,
- ICalComponent *inout_comp,
- ICalPropertyKind prop_kind)
-{
- ICalPropertyStatus status = I_CAL_STATUS_NONE;
+ e_m365_event_begin_recurrence (builder);
+ e_m365_patterned_recurrence_begin_pattern (builder);
- if (e_m365_event_get_is_cancelled (m365_event)) {
- status = I_CAL_STATUS_CANCELLED;
- } else {
- EM365ResponseStatus *response_status;
+ switch (i_cal_recurrence_get_freq (new_rrule)) {
+ case I_CAL_DAILY_RECURRENCE:
+ e_m365_recurrence_pattern_add_type (builder, E_M365_RECURRENCE_PATTERN_DAILY);
+ e_m365_recurrence_pattern_add_interval (builder,
i_cal_recurrence_get_interval (new_rrule));
+ ecb_m365_add_days_of_week_from_ical (builder, new_rrule);
+ break;
+ case I_CAL_WEEKLY_RECURRENCE:
+ e_m365_recurrence_pattern_add_type (builder,
E_M365_RECURRENCE_PATTERN_WEEKLY);
+ e_m365_recurrence_pattern_add_interval (builder,
i_cal_recurrence_get_interval (new_rrule));
- response_status = e_m365_event_get_response_status (m365_event);
+ week_day = ecb_m365_day_of_week_from_ical (i_cal_recurrence_get_week_start
(new_rrule));
- if (response_status) {
- EM365ResponseType response;
+ if (week_day != E_M365_DAY_OF_WEEK_UNKNOWN)
+ e_m365_recurrence_pattern_add_first_day_of_week (builder, week_day);
- response = e_m365_response_status_get_response (response_status);
+ ecb_m365_add_days_of_week_from_ical (builder, new_rrule);
+ break;
+ case I_CAL_MONTHLY_RECURRENCE:
+ by_pos = i_cal_recurrence_get_by_set_pos (new_rrule, 0);
- if (response == E_M365_RESPONSE_TENTATIVELY_ACCEPTED)
- status = I_CAL_STATUS_TENTATIVE;
- else if (response == E_M365_RESPONSE_ACCEPTED)
- status = I_CAL_STATUS_CONFIRMED;
- else if (response == E_M365_RESPONSE_DECLINED)
- status = I_CAL_STATUS_CANCELLED;
- else if (response == E_M365_RESPONSE_NOT_RESPONDED)
- status = I_CAL_STATUS_NEEDSACTION;
+ e_m365_recurrence_pattern_add_interval (builder,
i_cal_recurrence_get_interval (new_rrule));
+
+ if (by_pos == I_CAL_RECURRENCE_ARRAY_MAX) {
+ e_m365_recurrence_pattern_add_type (builder,
E_M365_RECURRENCE_PATTERN_ABSOLUTE_MONTHLY);
+ e_m365_recurrence_pattern_add_day_of_month (builder,
i_cal_recurrence_get_by_month_day (new_rrule, 0));
+ } else {
+ e_m365_recurrence_pattern_add_type (builder,
E_M365_RECURRENCE_PATTERN_RELATIVE_MONTHLY);
+
+ week_day = ecb_m365_day_of_week_from_ical
(i_cal_recurrence_get_week_start (new_rrule));
+
+ if (week_day != E_M365_DAY_OF_WEEK_UNKNOWN)
+ e_m365_recurrence_pattern_add_first_day_of_week (builder,
week_day);
+
+ ecb_m365_add_days_of_week_from_ical (builder, new_rrule);
+ ecb_m365_add_index_from_ical (builder, by_pos);
+ }
+ break;
+ case I_CAL_YEARLY_RECURRENCE:
+ by_pos = i_cal_recurrence_get_by_set_pos (new_rrule, 0);
+
+ e_m365_recurrence_pattern_add_interval (builder,
i_cal_recurrence_get_interval (new_rrule));
+
+ month = i_cal_recurrence_get_by_month (new_rrule, 0);
+
+ if (month >= 1 && month <= 12)
+ e_m365_recurrence_pattern_add_month (builder, month);
+
+ if (by_pos == I_CAL_RECURRENCE_ARRAY_MAX) {
+ e_m365_recurrence_pattern_add_type (builder,
E_M365_RECURRENCE_PATTERN_ABSOLUTE_YEARLY);
+ e_m365_recurrence_pattern_add_day_of_month (builder,
i_cal_recurrence_get_by_month_day (new_rrule, 0));
+ } else {
+ e_m365_recurrence_pattern_add_type (builder,
E_M365_RECURRENCE_PATTERN_RELATIVE_YEARLY);
+
+ week_day = ecb_m365_day_of_week_from_ical
(i_cal_recurrence_get_week_start (new_rrule));
+
+ if (week_day != E_M365_DAY_OF_WEEK_UNKNOWN)
+ e_m365_recurrence_pattern_add_first_day_of_week (builder,
week_day);
+
+ ecb_m365_add_days_of_week_from_ical (builder, new_rrule);
+ ecb_m365_add_index_from_ical (builder, by_pos);
+ }
+
+ break;
+ default:
+ g_set_error (error, E_CLIENT_ERROR, E_CLIENT_ERROR_NOT_SUPPORTED,
+ _("Unknown recurrence frequency (%d)"), i_cal_recurrence_get_freq
(new_rrule));
+
+ success = FALSE;
+ break;
+ }
+
+ e_m365_patterned_recurrence_end_pattern (builder);
+ e_m365_patterned_recurrence_begin_range (builder);
+
+ dtstart = i_cal_component_get_dtstart (new_comp);
+ i_cal_time_get_date (dtstart, &yy, &mm, &dd);
+ g_clear_object (&dtstart);
+
+ e_m365_recurrence_range_add_start_date (builder, e_m365_date_encode (yy, mm, dd));
+
+ if (!i_cal_recurrence_get_count (new_rrule)) {
+ ICalTime *until;
+ gint yy = 0, mm = 0, dd = 0;
+
+ until = i_cal_recurrence_get_until (new_rrule);
+
+ if (until)
+ i_cal_time_get_date (until, &yy, &mm, &dd);
+
+ if (!until || yy == 0) {
+ e_m365_recurrence_range_add_type (builder,
E_M365_RECURRENCE_RANGE_NOEND);
+ } else {
+ e_m365_recurrence_range_add_type (builder,
E_M365_RECURRENCE_RANGE_ENDDATE);
+ e_m365_recurrence_range_add_end_date (builder, e_m365_date_encode
(yy, mm, dd));
+ }
+
+ g_clear_object (&until);
+ } else {
+ e_m365_recurrence_range_add_type (builder, E_M365_RECURRENCE_RANGE_NUMBERED);
+ e_m365_recurrence_range_add_number_of_occurrences (builder,
i_cal_recurrence_get_count (new_rrule));
+ }
+
+ e_m365_patterned_recurrence_end_range (builder);
+ e_m365_event_end_recurrence (builder);
}
+
+ g_clear_object (&new_rrule);
+ } else {
+ e_m365_event_add_null_recurrence (builder);
}
- if (status != I_CAL_STATUS_NONE)
- i_cal_component_take_property (inout_comp, i_cal_property_new_status (status));
+ g_clear_object (&new_value);
+ g_clear_object (&old_value);
+
+ return success;
}
static gboolean
@@ -1870,9 +2137,9 @@ struct _mappings {
SIMPLE_FIELD (I_CAL_LOCATION_PROPERTY, ecb_m365_get_location,
ecb_m365_add_location),
SIMPLE_FIELD (I_CAL_ORGANIZER_PROPERTY, ecb_m365_get_organizer,
ecb_m365_add_organizer),
SIMPLE_FIELD (I_CAL_ATTENDEE_PROPERTY, ecb_m365_get_attendees,
ecb_m365_add_attendees),
- SIMPLE_FIELD (I_CAL_RRULE_PROPERTY, ecb_m365_get_recurrence,
ecb_m365_add_recurrence),
SIMPLE_FIELD (I_CAL_PRIORITY_PROPERTY, ecb_m365_get_importance,
ecb_m365_add_importance),
SIMPLE_FIELD (I_CAL_STATUS_PROPERTY, ecb_m365_get_status, NULL),
+ COMPLEX_FIELD (I_CAL_RRULE_PROPERTY, ecb_m365_get_recurrence,
ecb_m365_add_recurrence),
COMPLEX_FIELD (I_CAL_X_PROPERTY, ecb_m365_get_reminder,
ecb_m365_add_reminder),
COMPLEX_FIELD_2 (I_CAL_ATTACH_PROPERTY, ecb_m365_get_attachments,
ecb_m365_add_attachments)
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]