Commit f2c79880 authored by Milan Crha's avatar Milan Crha

Miscellaneous changes for issues overlooked during port to libical-glib

parent 15a5bcaf
......@@ -153,6 +153,8 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
* we know the timezones are the same so we return TRUE. */
retval = TRUE;
} else {
gint is_daylight = 0; /* Its value is ignored, but libical-glib 3.0.5 API requires it */
/* If the TZIDs differ, we have to compare the UTC offsets
* of the start and end times, using their own timezones and
* the given timezone. */
......@@ -167,11 +169,11 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
offset1 = i_cal_timezone_get_utc_offset (
start_zone,
e_cal_component_datetime_get_value (start_datetime),
NULL);
&is_daylight);
offset2 = i_cal_timezone_get_utc_offset (
zone,
e_cal_component_datetime_get_value (start_datetime),
NULL);
&is_daylight);
if (offset1 != offset2)
goto out;
}
......@@ -187,11 +189,11 @@ cal_comp_util_compare_event_timezones (ECalComponent *comp,
offset1 = i_cal_timezone_get_utc_offset (
end_zone,
e_cal_component_datetime_get_value (end_datetime),
NULL);
&is_daylight);
offset2 = i_cal_timezone_get_utc_offset (
zone,
e_cal_component_datetime_get_value (end_datetime),
NULL);
&is_daylight);
if (offset1 != offset2)
goto out;
}
......@@ -859,7 +861,7 @@ cal_comp_get_instance_times (ECalClient *client,
GCancellable *cancellable)
{
ICalTime *start_time, *end_time;
const ICalTimezone *zone = default_zone;
const ICalTimezone *zone;
g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (icomp != NULL);
......@@ -876,6 +878,8 @@ cal_comp_get_instance_times (ECalClient *client,
end_time = i_cal_time_clone (start_time);
}
zone = NULL;
if (i_cal_time_get_timezone (start_time)) {
zone = i_cal_time_get_timezone (start_time);
} else {
......@@ -903,8 +907,19 @@ cal_comp_get_instance_times (ECalClient *client,
}
}
if (!zone)
zone = default_zone;
*out_instance_start = i_cal_time_clone (start_time);
i_cal_time_set_timezone (*out_instance_start, zone);
if (i_cal_time_is_date (*out_instance_start)) {
i_cal_time_set_is_date (*out_instance_start, FALSE);
i_cal_time_set_timezone (*out_instance_start, zone);
i_cal_time_set_is_date (*out_instance_start, TRUE);
} else {
i_cal_time_set_timezone (*out_instance_start, zone);
}
zone = NULL;
if (i_cal_time_get_timezone (end_time)) {
zone = i_cal_time_get_timezone (end_time);
......@@ -936,8 +951,17 @@ cal_comp_get_instance_times (ECalClient *client,
}
}
if (!zone)
zone = default_zone;
*out_instance_end = i_cal_time_clone (end_time);
i_cal_time_set_timezone (*out_instance_end, zone);
if (i_cal_time_is_date (*out_instance_end)) {
i_cal_time_set_is_date (*out_instance_end, FALSE);
i_cal_time_set_timezone (*out_instance_end, zone);
i_cal_time_set_is_date (*out_instance_end, TRUE);
} else {
i_cal_time_set_timezone (*out_instance_end, zone);
}
g_clear_object (&start_time);
g_clear_object (&end_time);
......
......@@ -1147,8 +1147,8 @@ cal_data_model_instance_generated (ICalComponent *icomp,
cal_comp_get_instance_times (gid->client, e_cal_component_get_icalcomponent (comp_copy),
gid->zone, &tt, &tt2, cancellable);
start_tt = i_cal_time_as_timet (tt);
end_tt = i_cal_time_as_timet (tt2);
start_tt = i_cal_time_as_timet_with_zone (tt, i_cal_time_get_timezone (tt));
end_tt = i_cal_time_as_timet_with_zone (tt2, i_cal_time_get_timezone (tt2));
g_clear_object (&tt);
g_clear_object (&tt2);
......@@ -1325,8 +1325,8 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
cal_comp_get_instance_times (client, icomp, data_model->priv->zone, &start_tt, &end_tt, NULL);
instance_start = i_cal_time_as_timet (start_tt);
instance_end = i_cal_time_as_timet (end_tt);
instance_start = i_cal_time_as_timet_with_zone (start_tt, i_cal_time_get_timezone (start_tt));
instance_end = i_cal_time_as_timet_with_zone (end_tt, i_cal_time_get_timezone (end_tt));
g_clear_object (&start_tt);
g_clear_object (&end_tt);
......
......@@ -4119,8 +4119,10 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data,
cal_comp_get_instance_times (comp_data->client, comp_data->icalcomp, zone,
&instance_start, &instance_end, NULL);
comp_data->instance_start = instance_start ? i_cal_time_as_timet (instance_start) : comp_data->instance_start;
comp_data->instance_end = instance_end ? i_cal_time_as_timet (instance_end) : comp_data->instance_end;
comp_data->instance_start = instance_start ? i_cal_time_as_timet_with_zone (instance_start,
i_cal_time_get_timezone (instance_start)) : comp_data->instance_start;
comp_data->instance_end = instance_end ? i_cal_time_as_timet_with_zone (instance_end,
i_cal_time_get_timezone (instance_end)) : comp_data->instance_end;
g_clear_object (&instance_start);
g_clear_object (&instance_end);
......
......@@ -395,25 +395,20 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
}
duration = e_cal_component_alarm_trigger_get_duration (trigger);
switch (i_cal_duration_is_neg (duration)) {
case 1:
if (!duration || i_cal_duration_is_neg (duration))
e_dialog_combo_box_set (page_reminders->priv->relative_time_combo, BEFORE, relative_map);
break;
case 0:
else
e_dialog_combo_box_set (page_reminders->priv->relative_time_combo, AFTER, relative_map);
break;
}
if (i_cal_duration_get_days (duration)) {
if (duration && i_cal_duration_get_days (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, DAYS, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
i_cal_duration_get_days (duration));
} else if (i_cal_duration_get_hours (duration)) {
} else if (duration && i_cal_duration_get_hours (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, HOURS, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
i_cal_duration_get_hours (duration));
} else if (i_cal_duration_get_minutes (duration)) {
} else if (duration && i_cal_duration_get_minutes (duration)) {
e_dialog_combo_box_set (page_reminders->priv->unit_combo, MINUTES, value_map);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->time_spin),
i_cal_duration_get_minutes (duration));
......@@ -425,7 +420,7 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
/* Repeat options */
repeat = e_cal_component_alarm_get_repeat (alarm);
if (e_cal_component_alarm_repeat_get_repetitions (repeat)) {
if (repeat && e_cal_component_alarm_repeat_get_repetitions (repeat)) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page_reminders->priv->repeat_check), TRUE);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (page_reminders->priv->repeat_times_spin),
e_cal_component_alarm_repeat_get_repetitions (repeat));
......
......@@ -353,6 +353,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
* local time and the other timezone */
ICalTimezone *cal_zone;
ICalTime *tt;
gint is_daylight = 0; /* Its value is ignored, but libical-glib 3.0.5 API requires it */
gint diff;
struct tm mn;
......@@ -362,8 +363,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
day_view->day_starts[0], 0, cal_zone);
/* diff is number of minutes */
diff = (i_cal_timezone_get_utc_offset (use_zone, tt, NULL) -
i_cal_timezone_get_utc_offset (cal_zone, tt, NULL)) / 60;
diff = (i_cal_timezone_get_utc_offset (use_zone, tt, &is_daylight) -
i_cal_timezone_get_utc_offset (cal_zone, tt, &is_daylight)) / 60;
g_clear_object (&tt);
......
......@@ -683,7 +683,7 @@ meeting_store_set_property (GObject *object,
case PROP_TIMEZONE:
e_meeting_store_set_timezone (
E_MEETING_STORE (object),
g_value_get_pointer (value));
g_value_get_object (value));
return;
}
......@@ -733,7 +733,7 @@ meeting_store_get_property (GObject *object,
return;
case PROP_TIMEZONE:
g_value_set_pointer (
g_value_set_object (
value,
e_meeting_store_get_timezone (
E_MEETING_STORE (object)));
......@@ -857,10 +857,11 @@ e_meeting_store_class_init (EMeetingStoreClass *class)
g_object_class_install_property (
object_class,
PROP_TIMEZONE,
g_param_spec_pointer (
g_param_spec_object (
"timezone",
"Timezone",
NULL,
I_CAL_TYPE_TIMEZONE,
G_PARAM_READWRITE));
}
......
......@@ -406,8 +406,8 @@ get_component_julian_range (ECalClient *client,
cal_comp_get_instance_times (client, e_cal_component_get_icalcomponent (comp),
zone, &instance_start, &instance_end, NULL);
start_tt = i_cal_time_as_timet (instance_start);
end_tt = i_cal_time_as_timet (instance_end);
start_tt = i_cal_time_as_timet_with_zone (instance_start, i_cal_time_get_timezone (instance_start));
end_tt = i_cal_time_as_timet_with_zone (instance_end, i_cal_time_get_timezone (instance_end));
*start_julian = encode_timet_to_julian (start_tt, i_cal_time_is_date (instance_start), zone);
*end_julian = encode_timet_to_julian (end_tt - (end_tt == start_tt ? 0 : 1), i_cal_time_is_date (instance_end), zone);
......
......@@ -529,13 +529,14 @@ zone_display_name_with_offset (const ICalTimezone *zone)
const gchar *display_name;
struct tm local;
ICalTime *tt;
gint is_daylight = 0; /* Its value is ignored, but libical-glib 3.0.5 API requires it */
gint offset;
gchar buffer[100];
time_t now = time (NULL);
gmtime_r ((const time_t *) &now, &local);
tt = e_cal_util_tm_to_icaltime (&local, TRUE);
offset = i_cal_timezone_get_utc_offset ((ICalTimezone *) zone, tt, NULL);
offset = i_cal_timezone_get_utc_offset ((ICalTimezone *) zone, tt, &is_daylight);
g_clear_object (&tt);
format_utc_offset (offset, buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment