[almanah] Events: Removed event ocurrences



commit fd8894a44ac27c3cf2075d355970da38a4f988cb
Author: Álvaro Peña <alvaropg gmail com>
Date:   Fri Jan 1 12:46:46 2016 +0100

    Events: Removed event ocurrences
    
    Due some kind of error in timezone calculation for an event ocurrence,
    we only use the event date to fix the event time displayed in the events
    zone.
    
    Added some adjusts to the timezone setup for an event.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759924

 src/event-factories/calendar-client.c |  138 ++++-----------------------------
 1 files changed, 14 insertions(+), 124 deletions(-)
---
diff --git a/src/event-factories/calendar-client.c b/src/event-factories/calendar-client.c
index f0f4726..3e58c81 100644
--- a/src/event-factories/calendar-client.c
+++ b/src/event-factories/calendar-client.c
@@ -531,7 +531,6 @@ get_time_from_property (icalcomponent         *ical,
   icalproperty        *prop;
   struct icaltimetype  ical_time;
   icalparameter       *param;
-  icaltimezone        *time_zone = NULL;
 
   prop = icalcomponent_get_first_property (ical, prop_kind);
   if (!prop)
@@ -540,14 +539,11 @@ get_time_from_property (icalcomponent         *ical,
   ical_time = get_prop_func (prop);
 
   param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
-  if (param)
-    time_zone = icaltimezone_get_builtin_timezone_from_tzid (icalparameter_get_tzid (param));
-  else if (icaltime_is_utc (ical_time))
-    time_zone = icaltimezone_get_utc_timezone ();
-  else
-    time_zone = default_zone;
+  /* Use default timezone if the event doesn't provide its own timezone */
+  if (!param && !icaltime_is_utc (ical_time))
+    icaltime_set_timezone(&ical_time, default_zone);
 
-  return icaltime_as_timet_with_zone (ical_time, time_zone);
+  return icaltime_as_timet (ical_time);
 }
 
 static char *
@@ -844,69 +840,6 @@ calendar_appointment_init (CalendarAppointment  *appointment,
                                                    default_zone);
 }
 
-static icaltimezone *
-resolve_timezone_id (const char *tzid,
-                     gpointer user_data)
-{
-  icaltimezone *retval;
-  ECalClient *source = user_data;
-
-  retval = icaltimezone_get_builtin_timezone_from_tzid (tzid);
-  if (!retval)
-    {
-      e_cal_client_get_timezone_sync (source, tzid, &retval, NULL, NULL);
-    }
-
-  return retval;
-}
-
-static gboolean
-calendar_appointment_collect_occurrence (ECalComponent  *component,
-                                         time_t          occurrence_start,
-                                         time_t          occurrence_end,
-                                         gpointer        data)
-{
-  CalendarOccurrence *occurrence;
-  GSList **collect_loc = data;
-
-  occurrence             = g_new0 (CalendarOccurrence, 1);
-  occurrence->start_time = occurrence_start;
-  occurrence->end_time   = occurrence_end;
-
-  *collect_loc = g_slist_prepend (*collect_loc, occurrence);
-
-  return TRUE;
-}
-
-static void
-calendar_appointment_generate_ocurrences (CalendarAppointment *appointment,
-                                          icalcomponent       *ical,
-                                          ECalClient          *source,
-                                          time_t               start,
-                                          time_t               end,
-                                          icaltimezone        *default_zone)
-{
-  ECalComponent *ecal;
-
-  g_assert (appointment->occurrences == NULL);
-
-  ecal = e_cal_component_new ();
-  e_cal_component_set_icalcomponent (ecal,
-                                     icalcomponent_new_clone (ical));
-
-  e_cal_recur_generate_instances (ecal,
-                                  start,
-                                  end,
-                                  calendar_appointment_collect_occurrence,
-                                  &appointment->occurrences,
-                                  resolve_timezone_id,
-                                  source,
-                                  default_zone);
-
-  g_object_unref (ecal);
-
-  appointment->occurrences = g_slist_reverse (appointment->occurrences);
-}
 
 static inline gboolean
 calendar_task_equal (CalendarTask *a,
@@ -1138,24 +1071,6 @@ calendar_event_equal (CalendarEvent *a,
   return FALSE;
 }
 
-static void
-calendar_event_generate_ocurrences (CalendarEvent *event,
-                                    icalcomponent *ical,
-                                    ECalClient    *source,
-                                    time_t         start,
-                                    time_t         end,
-                                    icaltimezone  *default_zone)
-{
-  if (event->type != CALENDAR_EVENT_APPOINTMENT)
-    return;
-
-  calendar_appointment_generate_ocurrences (CALENDAR_APPOINTMENT (event),
-                                            ical,
-                                            source,
-                                            start,
-                                            end,
-                                            default_zone);
-}
 
 static inline void
 calendar_event_debug_dump (CalendarEvent *event)
@@ -1344,13 +1259,6 @@ calendar_client_handle_query_result (CalendarClientSource *source,
       if (!event)
         continue;
 
-      calendar_event_generate_ocurrences (event,
-                                          ical,
-                                          source->cal_client,
-                                          month_begin,
-                                          month_end,
-                                          client->priv->zone);
-
       uid = calendar_event_get_uid (event);
 
       old_event = g_hash_table_lookup (query->events, uid);
@@ -1834,41 +1742,23 @@ typedef void (* CalendarEventFilterFunc) (const char    *uid,
                                           FilterData    *filter_data);
 
 static void
-filter_appointment (const char    *uid,
-                    CalendarEvent *event,
-                    FilterData    *filter_data)
+filter_appointment (G_GNUC_UNUSED const char *uid,
+                    CalendarEvent            *event,
+                    FilterData               *filter_data)
 {
-  GSList *occurrences, *l;
-
   if (event->type != CALENDAR_EVENT_APPOINTMENT)
     return;
 
-  occurrences = CALENDAR_APPOINTMENT (event)->occurrences;
-  CALENDAR_APPOINTMENT (event)->occurrences = NULL;
-
-  for (l = occurrences; l; l = l->next)
+  if ((CALENDAR_APPOINTMENT(event)->start_time >= filter_data->start_time &&
+       CALENDAR_APPOINTMENT(event)->start_time < filter_data->end_time) ||
+      (CALENDAR_APPOINTMENT(event)->start_time <= filter_data->start_time &&
+       (CALENDAR_APPOINTMENT(event)->end_time - 1) > filter_data->start_time))
     {
-      CalendarOccurrence *occurrence = l->data;
-      time_t start_time = occurrence->start_time;
-      time_t end_time   = occurrence->end_time;
-
-      if ((start_time >= filter_data->start_time &&
-           start_time < filter_data->end_time) ||
-          (start_time <= filter_data->start_time &&
-           (end_time - 1) > filter_data->start_time))
-        {
-          CalendarEvent *new_event;
-
-          new_event = calendar_event_copy (event);
-
-          CALENDAR_APPOINTMENT (new_event)->start_time = occurrence->start_time;
-          CALENDAR_APPOINTMENT (new_event)->end_time   = occurrence->end_time;
+      CalendarEvent *new_event;
 
-          filter_data->events = g_slist_prepend (filter_data->events, new_event);
-        }
+      new_event = calendar_event_copy (event);
+      filter_data->events = g_slist_prepend (filter_data->events, new_event);
     }
-
-  CALENDAR_APPOINTMENT (event)->occurrences = occurrences;
 }
 
 static void


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