<p>Benoît Dereck-Tricot has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6625">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_calendar_icalendar: Filter out the occurrences superseded by an other VEVENT<br><br>When we are loading the calendars, we call libical's<br>icalcomponent_foreach_recurrence method for each VEVENT component that we have<br>in our calendar.<br>That method has no knowledge concerning the existence of the other VEVENT<br>components and will feed our callback with all ocurrences matching the requested<br>time span.<br>The occurrences generated by icalcomponent_foreach_recurrence while expanding a<br>recurring VEVENT's RRULE and RDATE properties can be superseded by an other<br>VEVENT sharing the same UID.<br>I use an external iterator (in libical terminology) to avoid messing with<br>the internal ones from the calling function, and search for VEVENTS which could<br>supersede the current occurrence.<br>The event which can invalidate this occurence needs to have<br>- the same UID as our recurrent component (comp)<br>- a RECURRENCE-ID property, which represents the start time of this occurrence<br>If one component is found, just clean and return<br><br>ASTERISK-27296<br><br>Change-Id: I8587ae3eaa765af7cb21eda3b6bf84e8a1c87af8<br>---<br>M res/res_calendar_icalendar.c<br>1 file changed, 32 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/25/6625/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_calendar_icalendar.c b/res/res_calendar_icalendar.c<br>index a6ce627..73443d7 100644<br>--- a/res/res_calendar_icalendar.c<br>+++ b/res/res_calendar_icalendar.c<br>@@ -251,7 +251,38 @@<br>               }<br>     }<br> <br>- /* Get the attendees */<br>+    /*<br>+     * If comp has an RRULE and/or RDATE property, we need to check whether an other vevent component<br>+     * supersedes this span. Such a component would have two characteristics:<br>+     *  - its UID is the same as comp<br>+     *  - its RECURRENCE-ID property is the same time as span->start<br>+     */<br>+    if (   icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY)<br>+        || icalcomponent_get_first_property(comp, ICAL_RDATE_PROPERTY)) {<br>+        icalcompiter comp_iter;<br>+        icaltimetype span_start = icaltime_from_timet_with_zone(event->start,<br>+                                                                icaltime_is_date(start),<br>+                                                                icaltime_get_timezone(start));<br>+        icaltime_set_timezone(&span_start, icaltime_get_timezone(start));<br>+<br>+        for (comp_iter = icalcomponent_begin_component(pvt->data, ICAL_VEVENT_COMPONENT);<br>+             icalcompiter_deref(&comp_iter) != 0;<br>+             icalcompiter_next(&comp_iter)) {<br>+            icalcomponent *vevent = icalcompiter_deref(&comp_iter);<br>+            icalproperty *uid = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);<br>+<br>+            if ( uid && ! strcmp(icalproperty_get_value_as_string(uid), event->uid)) {<br>+                icaltimetype recurrence_id = icalcomponent_get_recurrenceid(vevent);<br>+                if ( ! (icaltime_compare(recurrence_id, span_start))<br>+                     && (icaltime_is_date(span_start) == icaltime_is_date(recurrence_id))) {<br>+                    event = ast_calendar_unref_event(event);<br>+                    return;<br>+                }<br>+            }<br>+        }<br>+    }<br>+<br>+    /* Get the attendees */<br>   for (prop = icalcomponent_get_first_property(comp, ICAL_ATTENDEE_PROPERTY);<br>                   prop; prop = icalcomponent_get_next_property(comp, ICAL_ATTENDEE_PROPERTY)) {<br>                 struct ast_calendar_attendee *attendee;<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6625">change 6625</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6625"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8587ae3eaa765af7cb21eda3b6bf84e8a1c87af8 </div>
<div style="display:none"> Gerrit-Change-Number: 6625 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Benoît Dereck-Tricot <benoit.dereck-tricot@eyepea.eu> </div>