[evolution/wip/mcrha/eds-libical-glib] More changes in src/calendar/gui/
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/eds-libical-glib] More changes in src/calendar/gui/
- Date: Wed, 20 Mar 2019 16:39:46 +0000 (UTC)
commit 94e75d8f7ea25ae1f093e314a1533013d336b512
Author: Milan Crha <mcrha redhat com>
Date: Wed Mar 20 17:39:11 2019 +0100
More changes in src/calendar/gui/
- e-alarm-list.c
- e-cal-component-preview.c
- e-cal-data-model*.c
- e-cal-dialogs.c
- e-cal-list-view.c
src/calendar/gui/e-alarm-list.c | 69 ++++----
src/calendar/gui/e-cal-component-preview.c | 185 +++++++++++----------
src/calendar/gui/e-cal-data-model-subscriber.c | 2 +-
src/calendar/gui/e-cal-data-model.c | 134 ++++++++-------
src/calendar/gui/e-cal-dialogs.c | 141 ++++++++--------
src/calendar/gui/e-cal-list-view.c | 87 ++++++----
src/calendar/gui/e-cal-ops.c | 2 +-
src/calendar/gui/e-comp-editor-page-reminders.c | 6 +-
src/calendar/gui/e-task-table.c | 4 +-
src/calendar/gui/itip-utils.c | 10 +-
src/modules/calendar/e-cal-shell-view-private.c | 4 +-
src/modules/itip-formatter/itip-view.c | 13 +-
src/plugins/publish-calendar/publish-format-ical.c | 2 +-
src/plugins/save-calendar/ical-format.c | 2 +-
14 files changed, 349 insertions(+), 312 deletions(-)
---
diff --git a/src/calendar/gui/e-alarm-list.c b/src/calendar/gui/e-alarm-list.c
index 15f60733ac..1d80e8ec3b 100644
--- a/src/calendar/gui/e-alarm-list.c
+++ b/src/calendar/gui/e-alarm-list.c
@@ -246,7 +246,7 @@ free_alarm (ECalComponentAlarm *alarm)
static ECalComponentAlarm *
copy_alarm (const ECalComponentAlarm *alarm)
{
- return e_cal_component_alarm_clone ((ECalComponentAlarm *) alarm);
+ return e_cal_component_alarm_copy ((ECalComponentAlarm *) alarm);
}
void
@@ -355,64 +355,63 @@ e_alarm_list_get_path (GtkTreeModel *tree_model,
/* Builds a string for the duration of the alarm. If the duration is zero, returns NULL. */
static gchar *
-get_alarm_duration_string (struct icaldurationtype *duration)
+get_alarm_duration_string (ICalDurationType *duration)
{
GString *string = g_string_new (NULL);
- gchar *ret;
gboolean have_something;
+ guint value;
have_something = FALSE;
- if (duration->days >= 1) {
+ value = i_cal_duration_type_get_days (duration);
+ if (value >= 1) {
/* Translator: Entire string is like "Pop up an alert %d days before start" */
- g_string_printf (string, ngettext ("%d day", "%d days", duration->days), duration->days);
+ g_string_printf (string, ngettext ("%d day", "%d days", value), value);
have_something = TRUE;
}
- if (duration->weeks >= 1) {
+ value = i_cal_duration_type_get_weeks (duration);
+ if (value >= 1) {
/* Translator: Entire string is like "Pop up an alert %d weeks before start" */
- g_string_printf (string, ngettext ("%d week","%d weeks", duration->weeks), duration->weeks);
+ g_string_printf (string, ngettext ("%d week","%d weeks", value), value);
have_something = TRUE;
}
- if (duration->hours >= 1) {
+ value = i_cal_duration_type_get_hours (duration);
+ if (value >= 1) {
/* Translator: Entire string is like "Pop up an alert %d hours before start" */
- g_string_printf (string, ngettext ("%d hour", "%d hours", duration->hours), duration->hours);
+ g_string_printf (string, ngettext ("%d hour", "%d hours", value), value);
have_something = TRUE;
}
- if (duration->minutes >= 1) {
+ value = i_cal_duration_type_get_minutes (duration);
+ if (value >= 1) {
/* Translator: Entire string is like "Pop up an alert %d minutes before start" */
- g_string_printf (string, ngettext ("%d minute", "%d minutes", duration->minutes),
duration->minutes);
+ g_string_printf (string, ngettext ("%d minute", "%d minutes", value), value);
have_something = TRUE;
}
- if (duration->seconds >= 1) {
+ value = i_cal_duration_type_get_seconds (duration);
+ if (value >= 1) {
/* Translator: Entire string is like "Pop up an alert %d seconds before start" */
- g_string_printf (string, ngettext ("%d second", "%d seconds", duration->seconds),
duration->seconds);
+ g_string_printf (string, ngettext ("%d second", "%d seconds", value), value);
have_something = TRUE;
}
- if (have_something) {
- ret = string->str;
- g_string_free (string, FALSE);
- return ret;
- } else {
- g_string_free (string, TRUE);
- return NULL;
- }
+ return g_string_free (string, !have_something);
}
static gchar *
get_alarm_string (ECalComponentAlarm *alarm)
{
ECalComponentAlarmAction action;
- ECalComponentAlarmTrigger trigger;
+ ECalComponentAlarmTrigger *trigger;
+ ICalDurationType *duration;
const gchar *base;
gchar *str = NULL, *dur;
- e_cal_component_alarm_get_action (alarm, &action);
- e_cal_component_alarm_get_trigger (alarm, &trigger);
+ action = e_cal_component_alarm_get_action (alarm);
+ trigger = e_cal_component_alarm_get_trigger (alarm);
switch (action) {
case E_CAL_COMPONENT_ALARM_AUDIO:
@@ -440,12 +439,13 @@ get_alarm_string (ECalComponentAlarm *alarm)
/* FIXME: This does not look like it will localize correctly. */
- switch (trigger.type) {
+ switch (trigger ? e_cal_component_alarm_trigger_get_kind (trigger) :
E_CAL_COMPONENT_ALARM_TRIGGER_NONE) {
case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
- dur = get_alarm_duration_string (&trigger.u.rel_duration);
+ duration = e_cal_component_alarm_trigger_get_duration (trigger);
+ dur = get_alarm_duration_string (duration);
if (dur) {
- if (trigger.u.rel_duration.is_neg)
+ if (i_cal_duration_type_is_neg (duration))
str = g_strdup_printf (
/*Translator: The first %s refers to the base, which would be actions
like
* "Play a Sound". Second %s refers to the duration string e.g:"15
minutes"*/
@@ -467,10 +467,11 @@ get_alarm_string (ECalComponentAlarm *alarm)
break;
case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END:
- dur = get_alarm_duration_string (&trigger.u.rel_duration);
+ duration = e_cal_component_alarm_trigger_get_duration (trigger);
+ dur = get_alarm_duration_string (duration);
if (dur) {
- if (trigger.u.rel_duration.is_neg)
+ if (i_cal_duration_type_is_neg (duration))
str = g_strdup_printf (
/* Translator: The first %s refers to the base, which would be
actions like
* "Play a Sound". Second %s refers to the duration string e.g:"15
minutes" */
@@ -492,19 +493,19 @@ get_alarm_string (ECalComponentAlarm *alarm)
break;
case E_CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE: {
- struct icaltimetype itt;
- icaltimezone *utc_zone, *current_zone;
+ ICalTimetype *itt;
+ ICalTimezone *utc_zone, *current_zone;
struct tm tm;
gchar buf[256];
/* Absolute triggers come in UTC, so convert them to the local timezone */
- itt = trigger.u.abs_time;
+ itt = e_cal_component_alarm_trigger_get_absolute_time (trigger);
- utc_zone = icaltimezone_get_utc_timezone ();
+ utc_zone = i_cal_timezone_get_utc_timezone ();
current_zone = calendar_config_get_icaltimezone ();
- tm = icaltimetype_to_tm_with_zone (&itt, utc_zone, current_zone);
+ tm = icaltimetype_to_tm_with_zone (itt, utc_zone, current_zone);
e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (),
FALSE, FALSE, buf, sizeof (buf));
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index c751817b87..b0354baa60 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -48,12 +48,12 @@ struct _ECalComponentPreviewPrivate {
* if it didn't change then the preview is not updated */
gchar *cal_uid;
gchar *comp_uid;
- struct icaltimetype comp_last_modified;
+ ICalTimetype *comp_last_modified;
gint comp_sequence;
ECalClient *client;
ECalComponent *comp;
- icaltimezone *timezone;
+ ICalTimezone *timezone;
gboolean use_24_hour_format;
};
@@ -78,25 +78,22 @@ clear_comp_info (ECalComponentPreview *preview)
priv->cal_uid = NULL;
g_free (priv->comp_uid);
priv->comp_uid = NULL;
- priv->comp_last_modified = icaltime_null_time ();
priv->comp_sequence = -1;
+ g_clear_object (&priv->comp_last_modified);
g_clear_object (&priv->client);
g_clear_object (&priv->comp);
- if (priv->timezone) {
- icaltimezone_free (priv->timezone, 1);
- priv->timezone = NULL;
- }
+ g_clear_object (&priv->timezone);
}
/* Stores information about actually shown component and
* returns whether component in the preview changed */
static gboolean
update_comp_info (ECalComponentPreview *preview,
- ECalClient *client,
- ECalComponent *comp,
- icaltimezone *zone,
- gboolean use_24_hour_format)
+ ECalClient *client,
+ ECalComponent *comp,
+ ICalTimezone *zone,
+ gboolean use_24_hour_format)
{
ECalComponentPreviewPrivate *priv;
gboolean changed;
@@ -114,32 +111,27 @@ update_comp_info (ECalComponentPreview *preview,
const gchar *uid;
gchar *cal_uid;
gchar *comp_uid;
- struct icaltimetype comp_last_modified, *itm = NULL;
- gint *sequence = NULL;
+ ICalTimetype *comp_last_modified;
gint comp_sequence;
source = e_client_get_source (E_CLIENT (client));
cal_uid = g_strdup (e_source_get_uid (source));
- e_cal_component_get_uid (comp, &uid);
+ uid = e_cal_component_get_uid (comp);
comp_uid = g_strdup (uid);
- e_cal_component_get_last_modified (comp, &itm);
- if (itm) {
- comp_last_modified = *itm;
- e_cal_component_free_icaltimetype (itm);
- } else
- comp_last_modified = icaltime_null_time ();
- e_cal_component_get_sequence (comp, &sequence);
- if (sequence) {
- comp_sequence = *sequence;
- e_cal_component_free_sequence (sequence);
- } else
+ comp_last_modified = e_cal_component_get_last_modified (comp);
+ comp_sequence = e_cal_component_get_sequence (comp);
+ if (comp_sequence < 0)
comp_sequence = 0;
changed = !priv->cal_uid || !priv->comp_uid || !cal_uid || !comp_uid ||
!g_str_equal (priv->cal_uid, cal_uid) ||
!g_str_equal (priv->comp_uid, comp_uid) ||
- priv->comp_sequence != comp_sequence ||
- icaltime_compare (priv->comp_last_modified, comp_last_modified) != 0;
+ priv->comp_sequence != comp_sequence;
+
+ if (comp_last_modified && priv->comp_last_modified)
+ changed = changed || i_cal_time_compare (priv->comp_last_modified,
comp_last_modified) != 0;
+ else
+ changed = changed || comp_last_modified != priv->comp_last_modified;
clear_comp_info (preview);
@@ -150,7 +142,7 @@ update_comp_info (ECalComponentPreview *preview,
priv->comp = g_object_ref (comp);
priv->client = g_object_ref (client);
- priv->timezone = icaltimezone_copy (zone);
+ priv->timezone = i_cal_timezone_copy (zone);
priv->use_24_hour_format = use_24_hour_format;
}
@@ -160,26 +152,29 @@ update_comp_info (ECalComponentPreview *preview,
/* Converts a time_t to a string, relative to the specified timezone */
static gchar *
timet_to_str_with_zone (ECalComponentDateTime *dt,
- ECalClient *client,
- icaltimezone *default_zone)
+ ECalClient *client,
+ ICalTimezone *default_zone)
{
- struct icaltimetype itt;
- icaltimezone *zone = NULL;
+ ICalTimetype *itt;
+ ICalTimezone *zone = NULL;
struct tm tm;
- if (dt->tzid != NULL) {
- e_cal_client_get_timezone_sync (
- client, dt->tzid, &zone, NULL, NULL);
- } else if (icaltime_is_utc (*dt->value)) {
- zone = icaltimezone_get_utc_timezone ();
+ if (!dt)
+ return NULL;
+
+ itt = e_cal_component_datetime_get_value (dt);
+
+ if (e_cal_component_datetime_get_tzid (dt)) {
+ e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (dt), &zone, NULL,
NULL);
+ } else if (i_cal_time_is_utc (itt)) {
+ zone = i_cal_timezone_get_utc_timezone ();
}
- itt = *dt->value;
if (zone != NULL)
- icaltimezone_convert_time (&itt, zone, default_zone);
- tm = icaltimetype_to_tm (&itt);
+ i_cal_timezone_convert_time (itt, zone, default_zone);
+ tm = icaltimetype_to_tm (itt);
- return e_datetime_format_format_tm ("calendar", "table", itt.is_date ? DTFormatKindDate :
DTFormatKindDateTime, &tm);
+ return e_datetime_format_format_tm ("calendar", "table", i_cal_time_is_date (itt) ? DTFormatKindDate
: DTFormatKindDateTime, &tm);
}
static void
@@ -188,38 +183,39 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
{
ECalClient *client;
ECalComponent *comp;
- icaltimezone *default_zone;
- ECalComponentText text;
- ECalComponentDateTime dt;
+ ICalTimezone *default_zone;
+ ECalComponentText *text;
+ ECalComponentDateTime *dt;
gchar *str;
GString *string;
GSList *list, *iter;
- icalcomponent *icalcomp;
- icalproperty *icalprop;
- icalproperty_status status;
- const gchar *location, *url;
- gint *priority_value;
+ ICalComponent *icomp;
+ ICalProperty *prop;
+ ICalPropertyStatus status;
+ gchar *location, *url;
+ gint priority;
client = preview->priv->client;
comp = preview->priv->comp;
default_zone = preview->priv->timezone;
/* write document header */
- e_cal_component_get_summary (comp, &text);
+ text = e_cal_component_get_summary (comp);
g_string_append (buffer, HTML_HEADER);
g_string_append (buffer, "<body class=\"-e-web-view-background-color -e-web-view-text-color\">");
- if (text.value)
- g_string_append_printf (buffer, "<h2>%s</h2>", text.value);
+ if (text && e_cal_component_text_get_value (text))
+ g_string_append_printf (buffer, "<h2>%s</h2>", e_cal_component_text_get_value (text));
else
g_string_append_printf (buffer, "<h2><i>%s</i></h2>",_("Untitled"));
+ e_cal_component_text_free (text);
g_string_append (buffer, "<table border=\"0\" cellspacing=\"5\">");
/* write icons for the categories */
string = g_string_new (NULL);
- e_cal_component_get_categories_list (comp, &list);
+ list = e_cal_component_get_categories_list (comp);
if (list != NULL)
g_string_append_printf (buffer, "<tr><th>%s</th><td>", _("Categories:"));
for (iter = list; iter != NULL; iter = iter->next) {
@@ -247,52 +243,56 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_string_append_printf (buffer, "%s", string->str);
if (list != NULL)
g_string_append (buffer, "</td></tr>");
- e_cal_component_free_categories_list (list);
+ g_slist_free_full (list, g_free);
g_string_free (string, TRUE);
/* write location */
- e_cal_component_get_location (comp, &location);
+ location = e_cal_component_get_location (comp);
if (location && *location)
g_string_append_printf (
buffer, "<tr><th>%s</th><td>%s</td></tr>",
_("Location:"), location);
+ g_free (location);
/* write start date */
- e_cal_component_get_dtstart (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, client, default_zone);
+ dt = e_cal_component_get_dtstart (comp);
+ if (dt && e_cal_component_datetime_get_value (dt)) {
+ str = timet_to_str_with_zone (dt, client, default_zone);
g_string_append_printf (
buffer, "<tr><th>%s</th><td>%s</td></tr>",
_("Start Date:"), str);
g_free (str);
}
- e_cal_component_free_datetime (&dt);
+ e_cal_component_datetime_free (dt);
/* write end date */
- e_cal_component_get_dtend (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, client, default_zone);
+ dt = e_cal_component_get_dtend (comp);
+ if (dt && e_cal_component_datetime_get_value (dt)) {
+ str = timet_to_str_with_zone (dt, client, default_zone);
g_string_append_printf (
buffer,"<tr><th>%s</th><td>%s</td></tr>",
_("End Date:"), str);
g_free (str);
}
- e_cal_component_free_datetime (&dt);
+ e_cal_component_datetime_free (dt);
/* write Due Date */
- e_cal_component_get_due (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, client, default_zone);
+ dt = e_cal_component_get_due (comp);
+ if (dt && e_cal_component_datetime_get_value (dt)) {
+ str = timet_to_str_with_zone (dt, client, default_zone);
g_string_append_printf (
buffer, "<tr><th>%s</th><td>%s</td></tr>",
_("Due Date:"), str);
g_free (str);
}
- e_cal_component_free_datetime (&dt);
+ e_cal_component_datetime_free (dt);
- if (e_cal_util_component_has_recurrences (e_cal_component_get_icalcomponent (comp))) {
- str = e_cal_recur_describe_recurrence (e_cal_component_get_icalcomponent (comp),
- calendar_config_get_week_start_day (), E_CAL_RECUR_DESCRIBE_RECURRENCE_FLAG_NONE);
+ icomp = e_cal_component_get_icalcomponent (comp);
+
+ if (e_cal_util_component_has_recurrences (icomp)) {
+ str = e_cal_recur_describe_recurrence (icomp,
+ calendar_config_get_week_start_day (),
+ E_CAL_RECUR_DESCRIBE_RECURRENCE_FLAG_NONE);
if (str) {
g_string_append_printf (
@@ -303,25 +303,23 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
}
/* write status */
- icalcomp = e_cal_component_get_icalcomponent (comp);
- icalprop = icalcomponent_get_first_property (
- icalcomp, ICAL_STATUS_PROPERTY);
- if (icalprop != NULL) {
+ prop = i_cal_component_get_first_property (icomp, I_CAL_STATUS_PROPERTY);
+ if (prop) {
g_string_append_printf (
buffer, "<tr><th>%s</th>",
_("Status:"));
- e_cal_component_get_status (comp, &status);
+ status = e_cal_component_get_status (comp);
switch (status) {
- case ICAL_STATUS_INPROCESS :
+ case I_CAL_STATUS_INPROCESS :
str = g_strdup (_("In Progress"));
break;
- case ICAL_STATUS_COMPLETED :
+ case I_CAL_STATUS_COMPLETED :
str = g_strdup (_("Completed"));
break;
- case ICAL_STATUS_CANCELLED :
+ case I_CAL_STATUS_CANCELLED :
str = g_strdup (_("Cancelled"));
break;
- case ICAL_STATUS_NONE :
+ case I_CAL_STATUS_NONE :
default :
str = g_strdup (_("Not Started"));
break;
@@ -329,17 +327,19 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_string_append_printf (buffer, "<td>%s</td></tr>", str);
g_free (str);
+
+ g_object_unref (prop);
}
/* write priority */
- e_cal_component_get_priority (comp, &priority_value);
- if (priority_value && *priority_value != 0) {
+ priority = e_cal_component_get_priority (comp);
+ if (priority > 0) {
g_string_append_printf (
buffer, "<tr><th>%s</th>",
_("Priority:"));
- if (*priority_value <= 4)
+ if (priority <= 4)
str = g_strdup (_("High"));
- else if (*priority_value == 5)
+ else if (priority == 5)
str = g_strdup (_("Normal"));
else
str = g_strdup (_("Low"));
@@ -349,13 +349,10 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_free (str);
}
- if (priority_value)
- e_cal_component_free_priority (priority_value);
-
/* write description and URL */
g_string_append (buffer, "<tr><td colspan=\"2\"><hr></td></tr>");
- e_cal_component_get_description_list (comp, &list);
+ list = e_cal_component_get_descriptions (comp);
if (list) {
GSList *node;
@@ -368,9 +365,12 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
for (node = list; node != NULL; node = node->next) {
gchar *html;
- text = * (ECalComponentText *) node->data;
+ text = node->data;
+ if (!text || !e_cal_component_text_get_value (text))
+ continue;
+
html = camel_text_to_html (
- text.value ? text.value : "",
+ e_cal_component_text_get_value (text),
CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
@@ -384,11 +384,11 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_string_append (buffer, "</td></tr>");
- e_cal_component_free_text_list (list);
+ g_slist_free_full (list, e_cal_component_text_free);
}
/* URL */
- e_cal_component_get_url (comp, &url);
+ url = e_cal_component_get_url (comp);
if (url) {
gchar *scheme;
const gchar *href = url;
@@ -408,6 +408,7 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
_("Web Page:"), href, url);
g_free (str);
+ g_free (url);
}
g_string_append (buffer, "</table>");
@@ -500,7 +501,7 @@ void
e_cal_component_preview_display (ECalComponentPreview *preview,
ECalClient *client,
ECalComponent *comp,
- icaltimezone *zone,
+ ICalTimezone *zone,
gboolean use_24_hour_format)
{
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
diff --git a/src/calendar/gui/e-cal-data-model-subscriber.c b/src/calendar/gui/e-cal-data-model-subscriber.c
index 141a5cb08f..991c02aadd 100644
--- a/src/calendar/gui/e-cal-data-model-subscriber.c
+++ b/src/calendar/gui/e-cal-data-model-subscriber.c
@@ -31,7 +31,7 @@ e_cal_data_model_subscriber_default_init (ECalDataModelSubscriberInterface *ifac
* e_cal_data_model_subscriber_component_added:
* @subscriber: an #ECalDataModelSubscriber
* @client: an #ECalClient, which notifies about the component addition
- * @icalcomp: an #ECalComponent which was added
+ * @comp: an #ECalComponent which was added
*
* Notifies the @subscriber about an added component which belongs
* to the time range used by the @subscriber.
diff --git a/src/calendar/gui/e-cal-data-model.c b/src/calendar/gui/e-cal-data-model.c
index d66ef47c00..5eba636f0d 100644
--- a/src/calendar/gui/e-cal-data-model.c
+++ b/src/calendar/gui/e-cal-data-model.c
@@ -40,7 +40,7 @@ struct _ECalDataModelPrivate {
gboolean skip_cancelled;
gchar *filter;
gchar *full_filter; /* to be used with views */
- icaltimezone *zone;
+ ICalTimezone *zone;
time_t range_start;
time_t range_end;
@@ -91,7 +91,7 @@ typedef struct _ViewData {
GHashTable *components; /* ECalComponentId ~> ComponentData */
GHashTable *lost_components; /* ECalComponentId ~> ComponentData; when re-running view, valid till
'complete' is received */
gboolean received_complete;
- GSList *to_expand_recurrences; /* icalcomponent */
+ GSList *to_expand_recurrences; /* ICalComponent */
GSList *expanded_recurrences; /* ComponentData */
gint pending_expand_recurrences; /* how many is waiting to be processed */
@@ -138,8 +138,8 @@ static gboolean
component_data_equal (ComponentData *comp_data1,
ComponentData *comp_data2)
{
- icalcomponent *icomp1, *icomp2;
- struct icaltimetype tt1, tt2;
+ ICalComponent *icomp1, *icomp2;
+ ICalTimetype *tt1, *tt2;
gchar *as_str1, *as_str2;
gboolean equal;
@@ -157,28 +157,40 @@ component_data_equal (ComponentData *comp_data1,
icomp2 = e_cal_component_get_icalcomponent (comp_data2->component);
if (!icomp1 || !icomp2 ||
- icalcomponent_get_sequence (icomp1) != icalcomponent_get_sequence (icomp2) ||
- g_strcmp0 (icalcomponent_get_uid (icomp1), icalcomponent_get_uid (icomp2)) != 0)
+ i_cal_component_get_sequence (icomp1) != i_cal_component_get_sequence (icomp2) ||
+ g_strcmp0 (i_cal_component_get_uid (icomp1), i_cal_component_get_uid (icomp2)) != 0)
return FALSE;
- tt1 = icalcomponent_get_recurrenceid (icomp1);
- tt2 = icalcomponent_get_recurrenceid (icomp2);
- if ((icaltime_is_valid_time (tt1) ? 1 : 0) != (icaltime_is_valid_time (tt2) ? 1 : 0) ||
- (icaltime_is_null_time (tt1) ? 1 : 0) != (icaltime_is_null_time (tt2) ? 1 : 0) ||
- icaltime_compare (tt1, tt2) != 0)
+ tt1 = i_cal_component_get_recurrenceid (icomp1);
+ tt2 = i_cal_component_get_recurrenceid (icomp2);
+ if (((!tt1 || i_cal_time_is_valid_time (tt1)) ? 1 : 0) != ((!tt2 || i_cal_time_is_valid_time (tt2)) ?
1 : 0) ||
+ ((!tt1 || i_cal_time_is_null_time (tt1)) ? 1 : 0) != ((!tt2 || i_cal_time_is_null_time (tt2)) ? 1
: 0) ||
+ i_cal_time_compare (tt1, tt2) != 0) {
+ g_clear_object (&tt1);
+ g_clear_object (&tt2);
return FALSE;
+ }
+
+ g_clear_object (&tt1);
+ g_clear_object (&tt2);
- tt1 = icalcomponent_get_dtstamp (icomp1);
- tt2 = icalcomponent_get_dtstamp (icomp2);
- if ((icaltime_is_valid_time (tt1) ? 1 : 0) != (icaltime_is_valid_time (tt2) ? 1 : 0) ||
- (icaltime_is_null_time (tt1) ? 1 : 0) != (icaltime_is_null_time (tt2) ? 1 : 0) ||
- icaltime_compare (tt1, tt2) != 0)
+ tt1 = i_cal_component_get_dtstamp (icomp1);
+ tt2 = i_cal_component_get_dtstamp (icomp2);
+ if (((!tt1 || i_cal_time_is_valid_time (tt1)) ? 1 : 0) != ((!tt2 || i_cal_time_is_valid_time (tt2)) ?
1 : 0) ||
+ ((!tt1 || i_cal_time_is_null_time (tt1)) ? 1 : 0) != ((!tt2 || i_cal_time_is_null_time (tt2)) ? 1
: 0) ||
+ i_cal_time_compare (tt1, tt2) != 0) {
+ g_clear_object (&tt1);
+ g_clear_object (&tt2);
return FALSE;
+ }
+
+ g_clear_object (&tt1);
+ g_clear_object (&tt2);
/* Maybe not so effective compare, but might be still more effective
than updating whole UI with false notifications */
- as_str1 = icalcomponent_as_ical_string_r (icomp1);
- as_str2 = icalcomponent_as_ical_string_r (icomp2);
+ as_str1 = i_cal_component_as_ical_string_r (icomp1);
+ as_str2 = i_cal_component_as_ical_string_r (icomp2);
equal = g_strcmp0 (as_str1, as_str2) == 0;
@@ -201,8 +213,8 @@ view_data_new (ECalClient *client)
view_data->is_used = TRUE;
view_data->client = g_object_ref (client);
view_data->components = g_hash_table_new_full (
- (GHashFunc) e_cal_component_id_hash, (GEqualFunc) e_cal_component_id_equal,
- (GDestroyNotify) e_cal_component_free_id, component_data_free);
+ e_cal_component_id_hash, e_cal_component_id_equal,
+ e_cal_component_id_free, component_data_free);
return view_data;
}
@@ -254,7 +266,7 @@ view_data_unref (gpointer ptr)
g_hash_table_destroy (view_data->components);
if (view_data->lost_components)
g_hash_table_destroy (view_data->lost_components);
- g_slist_free_full (view_data->to_expand_recurrences, (GDestroyNotify)
icalcomponent_free);
+ g_slist_free_full (view_data->to_expand_recurrences, g_object_unref);
g_slist_free_full (view_data->expanded_recurrences, component_data_free);
g_rec_mutex_clear (&view_data->lock);
g_free (view_data);
@@ -657,7 +669,9 @@ cal_data_model_remove_one_view_component_cb (ECalDataModel *data_model,
g_return_if_fail (id != NULL);
- e_cal_data_model_subscriber_component_removed (subscriber, client, id->uid, id->rid);
+ e_cal_data_model_subscriber_component_removed (subscriber, client,
+ e_cal_component_id_get_uid (id),
+ e_cal_component_id_get_rid (id));
}
static void
@@ -763,8 +777,8 @@ cal_data_model_update_full_filter (ECalDataModel *data_model)
iso_start = isodate_from_time_t (range_start);
iso_end = isodate_from_time_t (range_end);
- if (data_model->priv->zone && data_model->priv->zone != icaltimezone_get_utc_timezone ())
- default_tzloc = icaltimezone_get_location (data_model->priv->zone);
+ if (data_model->priv->zone && data_model->priv->zone != i_cal_timezone_get_utc_timezone ())
+ default_tzloc = i_cal_timezone_get_location (data_model->priv->zone);
if (!default_tzloc)
default_tzloc = "";
@@ -890,7 +904,9 @@ cal_data_model_process_added_component (ECalDataModel *data_model,
if (g_hash_table_remove (new_subscribers, subscriber))
e_cal_data_model_subscriber_component_modified (subscriber,
view_data->client, comp_data->component);
else if (old_id)
- e_cal_data_model_subscriber_component_removed (subscriber,
view_data->client, old_id->uid, old_id->rid);
+ e_cal_data_model_subscriber_component_removed (subscriber,
view_data->client,
+ e_cal_component_id_get_uid (old_id),
+ e_cal_component_id_get_rid (old_id));
}
/* Those which left in the new_subscribers have the component added. */
@@ -912,8 +928,7 @@ cal_data_model_process_added_component (ECalDataModel *data_model,
view_data_unlock (view_data);
- if (old_id)
- e_cal_component_free_id (old_id);
+ e_cal_component_id_free (old_id);
}
typedef struct _GatherComponentsData {
@@ -939,7 +954,7 @@ cal_data_model_gather_components (gpointer key,
g_return_if_fail (gather_data->pcomponent_ids != NULL || gather_data->component_ids_hash != NULL);
g_return_if_fail (gather_data->pcomponent_ids == NULL || gather_data->component_ids_hash == NULL);
- if ((gather_data->all_instances || !comp_data->is_detached) && g_strcmp0 (id->uid, gather_data->uid)
== 0) {
+ if ((gather_data->all_instances || !comp_data->is_detached) && g_strcmp0 (e_cal_component_id_get_uid
(id), gather_data->uid) == 0) {
if (gather_data->component_ids_hash) {
ComponentData *comp_data_copy;
@@ -1000,21 +1015,21 @@ cal_data_model_notify_recurrences_cb (gpointer user_data)
gathered_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
known_instances = g_hash_table_new_full (
(GHashFunc) e_cal_component_id_hash, (GEqualFunc) e_cal_component_id_equal,
- (GDestroyNotify) e_cal_component_free_id, component_data_free);
+ (GDestroyNotify) e_cal_component_id_free, component_data_free);
for (link = expanded_recurrences; link && view_data->is_used; link = g_slist_next (link)) {
ComponentData *comp_data = link->data;
- icalcomponent *icomp;
+ ICalComponent *icomp;
const gchar *uid;
if (!comp_data)
continue;
icomp = e_cal_component_get_icalcomponent (comp_data->component);
- if (!icomp || !icalcomponent_get_uid (icomp))
+ if (!icomp || !i_cal_component_get_uid (icomp))
continue;
- uid = icalcomponent_get_uid (icomp);
+ uid = i_cal_component_get_uid (icomp);
if (!g_hash_table_contains (gathered_uids, uid)) {
GatherComponentsData gather_data;
@@ -1071,7 +1086,7 @@ cal_data_model_notify_recurrences_cb (gpointer user_data)
typedef struct
{
ECalClient *client;
- icaltimezone *zone;
+ ICalTimezone *zone;
GSList **pexpanded_recurrences;
gboolean skip_cancelled;
} GenerateInstancesData;
@@ -1190,7 +1205,7 @@ cal_data_model_expand_recurrences_thread (ECalDataModel *data_model,
view_data_unlock (view_data);
for (link = to_expand_recurrences; link && view_data->is_used; link = g_slist_next (link)) {
- icalcomponent *icomp = link->data;
+ ICalComponent *icomp = link->data;
GenerateInstancesData gid;
if (!icomp)
@@ -1198,14 +1213,16 @@ cal_data_model_expand_recurrences_thread (ECalDataModel *data_model,
gid.client = client;
gid.pexpanded_recurrences = &expanded_recurrences;
- gid.zone = data_model->priv->zone;
+ gid.zone = g_object_ref (data_model->priv->zone);
gid.skip_cancelled = data_model->priv->skip_cancelled;
e_cal_client_generate_instances_for_object_sync (client, icomp, range_start, range_end,
cal_data_model_instance_generated, &gid);
+
+ g_clear_object (&gid.zone);
}
- g_slist_free_full (to_expand_recurrences, (GDestroyNotify) icalcomponent_free);
+ g_slist_free_full (to_expand_recurrences, g_object_unref);
view_data_lock (view_data);
if (expanded_recurrences)
@@ -1277,9 +1294,9 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
cal_data_model_freeze_all_subscribers (data_model);
for (link = objects; link; link = g_slist_next (link)) {
- icalcomponent *icomp = link->data;
+ ICalComponent *icomp = link->data;
- if (!icomp || !icalcomponent_get_uid (icomp))
+ if (!icomp || !i_cal_component_get_uid (icomp))
continue;
if (data_model->priv->expand_recurrences &&
@@ -1288,7 +1305,7 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
/* This component requires an expand of recurrences, which
will be done in a dedicated thread, thus remember it */
to_expand_recurrences = g_slist_prepend (to_expand_recurrences,
- icalcomponent_new_clone (icomp));
+ i_cal_component_new_clone (icomp));
} else {
/* Single or detached instance, the simple case */
ECalComponent *comp;
@@ -1297,10 +1314,10 @@ cal_data_model_process_modified_or_added_objects (ECalClientView *view,
time_t instance_start, instance_end;
if (data_model->priv->skip_cancelled &&
- icalcomponent_get_status (icomp) == ICAL_STATUS_CANCELLED)
+ i_cal_component_get_status (icomp) == I_CAL_STATUS_CANCELLED)
continue;
- comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone
(icomp));
+ comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone
(icomp));
if (!comp)
continue;
@@ -1404,11 +1421,11 @@ cal_data_model_view_objects_removed (ECalClientView *view,
const ECalComponentId *id = link->data;
if (id) {
- if (!id->rid || !*id->rid) {
- if (!g_hash_table_contains (gathered_uids, id->uid)) {
+ if (!e_cal_component_id_get_rid (id)) {
+ if (!g_hash_table_contains (gathered_uids, e_cal_component_id_get_uid
(id))) {
GatherComponentsData gather_data;
- gather_data.uid = id->uid;
+ gather_data.uid = e_cal_component_id_get_uid (id);
gather_data.pcomponent_ids = &removed;
gather_data.component_ids_hash = NULL;
gather_data.copy_ids = TRUE;
@@ -1420,7 +1437,7 @@ cal_data_model_view_objects_removed (ECalClientView *view,
g_hash_table_foreach (view_data->lost_components,
cal_data_model_gather_components,
&gather_data);
- g_hash_table_insert (gathered_uids, id->uid, GINT_TO_POINTER
(1));
+ g_hash_table_insert (gathered_uids, (gpointer)
e_cal_component_id_get_uid (id), GINT_TO_POINTER (1));
}
} else {
removed = g_list_prepend (removed, e_cal_component_id_copy (id));
@@ -1462,7 +1479,7 @@ cal_data_model_view_objects_removed (ECalClientView *view,
cal_data_model_thaw_all_subscribers (data_model);
- g_list_free_full (removed, (GDestroyNotify) e_cal_component_free_id);
+ g_list_free_full (removed, (GDestroyNotify) e_cal_component_id_free);
g_hash_table_destroy (gathered_uids);
}
view_data_unlock (view_data);
@@ -1716,7 +1733,7 @@ cal_data_model_update_client_view (ECalDataModel *data_model,
view_data->lost_components = view_data->components;
view_data->components = g_hash_table_new_full (
(GHashFunc) e_cal_component_id_hash, (GEqualFunc) e_cal_component_id_equal,
- (GDestroyNotify) e_cal_component_free_id, component_data_free);
+ (GDestroyNotify) e_cal_component_id_free, component_data_free);
}
view_data_unlock (view_data);
@@ -1867,7 +1884,9 @@ cal_data_model_remove_from_subscriber_except_its_range (ECalDataModel *data_mode
time range will be removed */
if (!(instance_start <= subs_data->range_end &&
instance_end >= subs_data->range_start))
- e_cal_data_model_subscriber_component_removed (subs_data->subscriber, client, id->uid,
id->rid);
+ e_cal_data_model_subscriber_component_removed (subs_data->subscriber, client,
+ e_cal_component_id_get_uid (id),
+ e_cal_component_id_get_rid (id));
return TRUE;
}
@@ -1878,7 +1897,7 @@ cal_data_model_set_client_default_zone_cb (gpointer key,
gpointer user_data)
{
ECalClient *client = value;
- icaltimezone *zone = user_data;
+ ICalTimezone *zone = user_data;
g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (zone != NULL);
@@ -2032,6 +2051,7 @@ cal_data_model_finalize (GObject *object)
g_slist_free_full (data_model->priv->subscribers, subscriber_data_free);
g_free (data_model->priv->filter);
g_free (data_model->priv->full_filter);
+ g_clear_object (&data_model->priv->zone);
e_weak_ref_free (data_model->priv->submit_thread_job_responder);
g_rec_mutex_clear (&data_model->priv->props_lock);
@@ -2109,7 +2129,7 @@ e_cal_data_model_init (ECalDataModel *data_model)
data_model->priv->disposing = FALSE;
data_model->priv->expand_recurrences = FALSE;
data_model->priv->skip_cancelled = FALSE;
- data_model->priv->zone = icaltimezone_get_utc_timezone ();
+ data_model->priv->zone = g_object_ref (i_cal_timezone_get_utc_timezone ());
data_model->priv->views_update_freeze = 0;
data_model->priv->views_update_required = FALSE;
@@ -2367,14 +2387,14 @@ e_cal_data_model_set_skip_cancelled (ECalDataModel *data_model,
* Obtains a timezone being used for calendar views. The returned
* timezone is owned by the @data_model.
*
- * Returns: (transfer none): An #icaltimezone being used for calendar views.
+ * Returns: (transfer none): An #ICalTimezone being used for calendar views.
*
* Since: 3.16
**/
-icaltimezone *
+ICalTimezone *
e_cal_data_model_get_timezone (ECalDataModel *data_model)
{
- icaltimezone *zone;
+ ICalTimezone *zone;
g_return_val_if_fail (E_IS_CAL_DATA_MODEL (data_model), NULL);
@@ -2386,10 +2406,11 @@ e_cal_data_model_get_timezone (ECalDataModel *data_model)
return zone;
}
+
/**
* e_cal_data_model_set_timezone:
* @data_model: an #EDataModel instance
- * @zone: an #icaltimezone
+ * @zone: an #ICalTimezone
*
* Sets a trimezone to be used for calendar views. This change
* regenerates all views.
@@ -2398,7 +2419,7 @@ e_cal_data_model_get_timezone (ECalDataModel *data_model)
**/
void
e_cal_data_model_set_timezone (ECalDataModel *data_model,
- icaltimezone *zone)
+ ICalTimezone *zone)
{
g_return_if_fail (E_IS_CAL_DATA_MODEL (data_model));
g_return_if_fail (zone != NULL);
@@ -2406,7 +2427,8 @@ e_cal_data_model_set_timezone (ECalDataModel *data_model,
LOCK_PROPS ();
if (data_model->priv->zone != zone) {
- data_model->priv->zone = zone;
+ g_clear_object (&data_model->priv->zone);
+ data_model->priv->zone = g_object_ref (zone);
g_hash_table_foreach (data_model->priv->clients, cal_data_model_set_client_default_zone_cb,
zone);
diff --git a/src/calendar/gui/e-cal-dialogs.c b/src/calendar/gui/e-cal-dialogs.c
index 04974e3b91..e048c170c3 100644
--- a/src/calendar/gui/e-cal-dialogs.c
+++ b/src/calendar/gui/e-cal-dialogs.c
@@ -41,24 +41,22 @@
static gboolean
is_past_event (ECalComponent *comp)
{
- ECalComponentDateTime end_date;
+ ECalComponentDateTime *end_date;
gboolean res;
if (!comp)
return TRUE;
- end_date.value = NULL;
+ end_date = e_cal_component_get_dtend (comp);
- e_cal_component_get_dtend (comp, &end_date);
-
- if (!end_date.value)
+ if (!end_date)
return FALSE;
- res = icaltime_compare_date_only (
- *end_date.value,
- icaltime_current_time_with_zone (
- icaltime_get_timezone (*end_date.value))) == -1;
- e_cal_component_free_datetime (&end_date);
+ res = i_cal_time_compare_date_only (
+ e_cal_component_datetime_get_value (end_date),
+ i_cal_time_current_time_with_zone (i_cal_time_get_timezone
(e_cal_component_datetime_get_value (end_date)))) == -1;
+
+ e_cal_component_datetime_free (end_date);
return res;
}
@@ -157,11 +155,11 @@ struct ForeachTzidData
};
static void
-add_timezone_to_cal_cb (icalparameter *param,
+add_timezone_to_cal_cb (ICalParameter *param,
gpointer data)
{
struct ForeachTzidData *ftd = data;
- icaltimezone *tz = NULL;
+ ICalTimezone *tz = NULL;
const gchar *tzid;
g_return_if_fail (ftd != NULL);
@@ -171,7 +169,7 @@ add_timezone_to_cal_cb (icalparameter *param,
if (!ftd->success)
return;
- tzid = icalparameter_get_tzid (param);
+ tzid = i_cal_parameter_get_tzid (param);
if (!tzid || !*tzid)
return;
@@ -232,29 +230,29 @@ copy_source_thread (EAlertSinkThreadJobData *job_data,
n_objects = g_slist_length (objects);
for (link = objects, ii = 0; link && ftd.success && !g_cancellable_is_cancelled (cancellable); link =
g_slist_next (link), ii++) {
- icalcomponent *icalcomp = link->data;
- icalcomponent *existing_icalcomp = NULL;
+ ICalComponent *icomp = link->data;
+ ICalComponent *existing_icomp = NULL;
gint percent = 100 * (ii + 1) / n_objects;
GError *local_error = NULL;
- if (e_cal_client_get_object_sync (to_client, icalcomponent_get_uid (icalcomp), NULL,
&existing_icalcomp, cancellable, &local_error) &&
- icalcomp != NULL) {
- if (!e_cal_client_modify_object_sync (to_client, icalcomp, E_CAL_OBJ_MOD_ALL,
cancellable, error))
+ if (e_cal_client_get_object_sync (to_client, i_cal_component_get_uid (icomp), NULL,
&existing_icomp, cancellable, &local_error) &&
+ icomp != NULL) {
+ if (!e_cal_client_modify_object_sync (to_client, icomp, E_CAL_OBJ_MOD_ALL,
E_CAL_OPERATION_FLAG_NONE, cancellable, error))
break;
- icalcomponent_free (existing_icalcomp);
+ g_object_unref (existing_icomp);
} else if (local_error && !g_error_matches (local_error, E_CAL_CLIENT_ERROR,
E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
g_propagate_error (error, local_error);
break;
} else {
- icalcomponent_foreach_tzid (icalcomp, add_timezone_to_cal_cb, &ftd);
+ i_cal_component_foreach_tzid (icomp, add_timezone_to_cal_cb, &ftd);
g_clear_error (&local_error);
if (!ftd.success)
break;
- if (!e_cal_client_create_object_sync (to_client, icalcomp, NULL, cancellable, error))
+ if (!e_cal_client_create_object_sync (to_client, icomp, E_CAL_OPERATION_FLAG_NONE,
NULL, cancellable, error))
break;
}
@@ -267,7 +265,7 @@ copy_source_thread (EAlertSinkThreadJobData *job_data,
if (ii > 0 && ftd.success)
csd->to_client = g_object_ref (to_client);
out:
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
g_clear_object (&from_client);
g_clear_object (&to_client);
}
@@ -391,13 +389,16 @@ e_cal_dialogs_delete_component (ECalComponent *comp,
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
if (comp) {
- ECalComponentText summary;
-
vtype = e_cal_component_get_vtype (comp);
if (!consider_as_untitled) {
- e_cal_component_get_summary (comp, &summary);
- arg0 = g_strdup (summary.value);
+ ECalComponentText *summary;
+
+ summary = e_cal_component_get_summary (comp);
+ if (summary) {
+ arg0 = g_strdup (e_cal_component_text_get_value (summary));
+ e_cal_component_text_free (summary);
+ }
}
switch (vtype) {
@@ -431,9 +432,7 @@ e_cal_dialogs_delete_component (ECalComponent *comp,
break;
default:
- g_message (
- "delete_component_dialog(): Cannot handle object of type %d",
- vtype);
+ g_message ("%s: Cannot handle object of type %d", G_STRFUNC, vtype);
g_free (arg0);
return FALSE;
}
@@ -461,9 +460,7 @@ e_cal_dialogs_delete_component (ECalComponent *comp,
break;
default:
- g_message (
- "delete_component_dialog(): Cannot handle objects of type %d",
- vtype);
+ g_message ("%s: Cannot handle objects of type %d", G_STRFUNC, vtype);
return FALSE;
}
@@ -634,18 +631,21 @@ ecal_event (ECalendarItem *calitem,
{
GoToDialog *dlg = user_data;
GDate start_date, end_date;
- struct icaltimetype tt = icaltime_null_time ();
- icaltimezone *timezone;
+ ICalTimetype *tt = i_cal_time_null_time ();
+ ICalTimezone *timezone;
time_t et;
g_warn_if_fail (e_calendar_item_get_selection (calitem, &start_date, &end_date));
timezone = e_cal_data_model_get_timezone (dlg->data_model);
- tt.year = g_date_get_year (&start_date);
- tt.month = g_date_get_month (&start_date);
- tt.day = g_date_get_day (&start_date);
+ i_cal_timetype_set_date (tt,
+ g_date_get_year (&start_date),
+ g_date_get_month (&start_date),
+ g_date_get_day (&start_date));
+
+ et = i_cal_time_as_timet_with_zone (tt, timezone);
- et = icaltime_as_timet_with_zone (tt, timezone);
+ g_clear_object (&tt);
*(dlg->out_move_type) = E_CALENDAR_VIEW_MOVE_TO_EXACT_DAY;
*(dlg->out_exact_date) = et;
@@ -658,23 +658,18 @@ static struct tm
get_current_time (ECalendarItem *calitem,
gpointer data)
{
- icaltimezone *zone;
+ ICalTimezone *zone;
+ ICalTimetype *tt;
struct tm tmp_tm = { 0 };
- struct icaltimetype tt;
/* Get the current timezone. */
zone = calendar_config_get_icaltimezone ();
- tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
+ tt = i_cal_time_from_timet_with_zone (time (NULL), FALSE, zone);
- /* Now copy it to the struct tm and return it. */
- tmp_tm.tm_year = tt.year - 1900;
- tmp_tm.tm_mon = tt.month - 1;
- tmp_tm.tm_mday = tt.day;
- tmp_tm.tm_hour = tt.hour;
- tmp_tm.tm_min = tt.minute;
- tmp_tm.tm_sec = tt.second;
- tmp_tm.tm_isdst = -1;
+ tmp_tm = icaltimetype_to_tm (tt);
+
+ g_clear_object (&tt);
return tmp_tm;
}
@@ -790,15 +785,17 @@ e_cal_dialogs_goto_run (GtkWindow *parent,
dlg->month_val = g_date_get_month (from_date) - 1;
dlg->day_val = g_date_get_day (from_date);
} else {
- struct icaltimetype tt;
- icaltimezone *timezone;
+ ICalTimetype *tt;
+ ICalTimezone *timezone;
timezone = e_cal_data_model_get_timezone (dlg->data_model);
- tt = icaltime_current_time_with_zone (timezone);
+ tt = i_cal_time_current_time_with_zone (timezone);
+
+ dlg->year_val = i_cal_timetype_get_year (tt);
+ dlg->month_val = i_cal_timetype_get_month (tt) - 1;
+ dlg->day_val = i_cal_timetype_get_day (tt);
- dlg->year_val = tt.year;
- dlg->month_val = tt.month - 1;
- dlg->day_val = tt.day;
+ g_clear_object (&tt);
}
g_signal_connect (
@@ -909,13 +906,13 @@ e_cal_dialogs_recur_component (ECalClient *client,
rb_this = gtk_radio_button_new_with_label (NULL, _("This Instance Only"));
gtk_container_add (GTK_CONTAINER (vbox), rb_this);
- if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) {
+ if (!e_client_check_capability (E_CLIENT (client), E_CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) {
rb_prior = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This
and Prior Instances"));
gtk_container_add (GTK_CONTAINER (vbox), rb_prior);
} else
rb_prior = NULL;
- if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) {
+ if (!e_client_check_capability (E_CLIENT (client), E_CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) {
rb_future = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This
and Future Instances"));
gtk_container_add (GTK_CONTAINER (vbox), rb_future);
} else
@@ -949,7 +946,7 @@ e_cal_dialogs_recur_component (ECalClient *client,
gboolean
e_cal_dialogs_recur_icalcomp (ECalClient *client,
- icalcomponent *icalcomp,
+ ICalComponent *icomp,
ECalObjModType *mod,
GtkWindow *parent,
gboolean delegated)
@@ -957,9 +954,9 @@ e_cal_dialogs_recur_icalcomp (ECalClient *client,
ECalComponent *comp;
gboolean res;
- g_return_val_if_fail (icalcomp != NULL, FALSE);
+ g_return_val_if_fail (icomp != NULL, FALSE);
- comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (icalcomp));
+ comp = e_cal_component_new_from_icalcomponent (i_cal_component_new_clone (icomp));
if (!comp)
return FALSE;
@@ -1044,31 +1041,31 @@ component_has_new_attendees (ECalComponent *comp)
static gboolean
have_nonprocedural_alarm (ECalComponent *comp)
{
- GList *uids, *l;
+ GSList *uids, *link;
g_return_val_if_fail (comp != NULL, FALSE);
uids = e_cal_component_get_alarm_uids (comp);
- for (l = uids; l; l = l->next) {
+ for (link = uids; link; link = g_slist_next (link)) {
ECalComponentAlarm *alarm;
ECalComponentAlarmAction action = E_CAL_COMPONENT_ALARM_UNKNOWN;
- alarm = e_cal_component_get_alarm (comp, (const gchar *) l->data);
+ alarm = e_cal_component_get_alarm (comp, link->data);
if (alarm) {
- e_cal_component_alarm_get_action (alarm, &action);
+ action = e_cal_component_alarm_get_action (alarm);
e_cal_component_alarm_free (alarm);
if (action != E_CAL_COMPONENT_ALARM_NONE &&
action != E_CAL_COMPONENT_ALARM_PROCEDURE &&
action != E_CAL_COMPONENT_ALARM_UNKNOWN) {
- cal_obj_uid_list_free (uids);
+ g_slist_free_full (uids, g_free);
return TRUE;
}
}
}
- cal_obj_uid_list_free (uids);
+ g_slist_free_full (uids, g_free);
return FALSE;
}
@@ -1278,22 +1275,22 @@ e_cal_dialogs_send_dragged_or_resized_component (GtkWindow *parent,
gboolean
e_cal_dialogs_send_component_prompt_subject (GtkWindow *parent,
- icalcomponent *component)
+ ICalComponent *component)
{
- icalcomponent_kind kind;
+ ICalComponentKind kind;
const gchar *id;
- kind = icalcomponent_isa (component);
+ kind = i_cal_component_isa (component);
switch (kind) {
- case ICAL_VEVENT_COMPONENT:
+ case I_CAL_VEVENT_COMPONENT:
id = "calendar:prompt-save-no-subject-calendar";
break;
- case ICAL_VTODO_COMPONENT:
+ case I_CAL_VTODO_COMPONENT:
id = "calendar:prompt-save-no-subject-task";
break;
- case ICAL_VJOURNAL_COMPONENT:
+ case I_CAL_VJOURNAL_COMPONENT:
id = "calendar:prompt-send-no-subject-memo";
break;
diff --git a/src/calendar/gui/e-cal-list-view.c b/src/calendar/gui/e-cal-list-view.c
index f547e2b2a3..e1d210b13c 100644
--- a/src/calendar/gui/e-cal-list-view.c
+++ b/src/calendar/gui/e-cal-list-view.c
@@ -123,21 +123,16 @@ get_current_time_cb (ECellDateEdit *ecde,
gpointer data)
{
ECalListView *cal_list_view = data;
- icaltimezone *zone;
- struct tm tmp_tm = { 0 };
- struct icaltimetype tt;
+ ICalTimezone *zone;
+ ICalTimetype *tt;
+ struct tm tmp_tm;
zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (cal_list_view));
- tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone);
+ tt = i_cal_time_from_timet_with_zone (time (NULL), FALSE, zone);
- /* Now copy it to the struct tm and return it. */
- tmp_tm.tm_year = tt.year - 1900;
- tmp_tm.tm_mon = tt.month - 1;
- tmp_tm.tm_mday = tt.day;
- tmp_tm.tm_hour = tt.hour;
- tmp_tm.tm_min = tt.minute;
- tmp_tm.tm_sec = tt.second;
- tmp_tm.tm_isdst = -1;
+ tmp_tm = icaltimetype_to_tm (tt);
+
+ g_clear_object (&tt);
return tmp_tm;
}
@@ -491,38 +486,53 @@ e_cal_list_view_get_selected_time_range (ECalendarView *cal_view,
time_t *end_time)
{
GList *selected;
- icaltimezone *zone;
+ ICalTimezone *zone;
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
- ECalComponentDateTime dtstart, dtend;
ECalComponent *comp;
if (!is_comp_data_valid (event))
return FALSE;
comp = e_cal_component_new ();
- e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone
(event->comp_data->icalcomp));
+ e_cal_component_set_icalcomponent (comp, i_cal_component_new_clone
(event->comp_data->icalcomp));
if (start_time) {
- e_cal_component_get_dtstart (comp, &dtstart);
- if (dtstart.tzid) {
- zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (comp),
dtstart.tzid);
+ ECalComponentDateTime *dt;
+
+ dt = e_cal_component_get_dtstart (comp);
+
+ if (dt) {
+ if (e_cal_component_datetime_get_tzid (dt)) {
+ zone = i_cal_component_get_timezone
(e_cal_component_get_icalcomponent (comp), e_cal_component_datetime_get_tzid (dt));
+ } else {
+ zone = NULL;
+ }
+ *start_time = i_cal_time_as_timet_with_zone
(e_cal_component_datetime_get_value (dt), zone);
} else {
- zone = NULL;
+ *start_time = (time_t) 0;
}
- *start_time = icaltime_as_timet_with_zone (*dtstart.value, zone);
- e_cal_component_free_datetime (&dtstart);
+
+ e_cal_component_datetime_free (dt);
}
if (end_time) {
- e_cal_component_get_dtend (comp, &dtend);
- if (dtend.tzid) {
- zone = icalcomponent_get_timezone (e_cal_component_get_icalcomponent (comp),
dtend.tzid);
+ ECalComponentDateTime *dt;
+
+ dt = e_cal_component_get_dtend (comp);
+
+ if (dt) {
+ if (e_cal_component_datetime_get_tzid (dt)) {
+ zone = i_cal_component_get_timezone
(e_cal_component_get_icalcomponent (comp), e_cal_component_datetime_get_tzid (dt));
+ } else {
+ zone = NULL;
+ }
+ *end_time = i_cal_time_as_timet_with_zone (e_cal_component_datetime_get_value
(dt), zone);
} else {
- zone = NULL;
+ *end_time = (time_t) 0;
}
- *end_time = icaltime_as_timet_with_zone (*dtend.value, zone);
- e_cal_component_free_datetime (&dtend);
+
+ e_cal_component_datetime_free (dt);
}
g_object_unref (comp);
@@ -562,22 +572,27 @@ e_cal_list_view_get_selected_events (ECalendarView *cal_view)
return event_list;
}
+/* It also frees 'itt' */
static void
-adjust_range (icaltimetype icaltime,
+adjust_range (ICalTimetype *itt,
time_t *earliest,
time_t *latest,
gboolean *set)
{
time_t t;
- if (!icaltime_is_valid_time (icaltime))
+ if (!itt || !i_cal_time_is_valid_time (itt)) {
+ g_clear_object (&itt);
return;
+ }
+
+ t = i_cal_time_as_timet (itt);
- t = icaltime_as_timet (icaltime);
*earliest = MIN (*earliest, t);
*latest = MAX (*latest, t);
-
*set = TRUE;
+
+ g_clear_object (&itt);
}
/* NOTE: Time use for this function increases linearly with number of events.
@@ -596,18 +611,18 @@ e_cal_list_view_get_visible_time_range (ECalendarView *cal_view,
for (i = 0; i < n_rows; i++) {
ECalModelComponent *comp;
- icalcomponent *icalcomp;
+ ICalComponent *icomp;
comp = e_cal_model_get_component_at (e_calendar_view_get_model (cal_view), i);
if (!comp)
continue;
- icalcomp = comp->icalcomp;
- if (!icalcomp)
+ icomp = comp->icalcomp;
+ if (!icomp)
continue;
- adjust_range (icalcomponent_get_dtstart (icalcomp), &earliest, &latest, &set);
- adjust_range (icalcomponent_get_dtend (icalcomp), &earliest, &latest, &set);
+ adjust_range (i_cal_component_get_dtstart (icomp), &earliest, &latest, &set);
+ adjust_range (i_cal_component_get_dtend (icomp), &earliest, &latest, &set);
}
if (set) {
diff --git a/src/calendar/gui/e-cal-ops.c b/src/calendar/gui/e-cal-ops.c
index b885aa6926..f7d27da6e4 100644
--- a/src/calendar/gui/e-cal-ops.c
+++ b/src/calendar/gui/e-cal-ops.c
@@ -1178,7 +1178,7 @@ cal_ops_delete_completed_thread (EAlertSinkThreadJobData *job_data,
}
}
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
/* did not process all objects => an error occurred */
if (olink != NULL)
diff --git a/src/calendar/gui/e-comp-editor-page-reminders.c b/src/calendar/gui/e-comp-editor-page-reminders.c
index 47a21457c7..6ab164a8a0 100644
--- a/src/calendar/gui/e-comp-editor-page-reminders.c
+++ b/src/calendar/gui/e-comp-editor-page-reminders.c
@@ -1386,7 +1386,7 @@ ecep_reminders_fill_widgets (ECompEditorPage *page,
comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (component));
if (comp && e_cal_component_has_alarms (comp)) {
- GList *alarms, *link;
+ GSList *alarms, *link;
gint alarm_type;
alarms = e_cal_component_get_alarm_uids (comp);
@@ -1399,7 +1399,7 @@ ecep_reminders_fill_widgets (ECompEditorPage *page,
e_alarm_list_clear (page_reminders->priv->alarm_list);
- for (link = alarms; link; link = g_list_next (link)) {
+ for (link = alarms; link; link = g_slist_next (link)) {
ECalComponentAlarm *ca;
const gchar *uid = link->data;
@@ -1408,7 +1408,7 @@ ecep_reminders_fill_widgets (ECompEditorPage *page,
e_cal_component_alarm_free (ca);
}
- cal_obj_uid_list_free (alarms);
+ g_slist_free_full (alarms, g_free);
if (e_dialog_combo_box_get (page_reminders->priv->alarms_combo,
page_reminders->priv->alarm_map) == ALARM_CUSTOM) {
GtkTreeSelection *selection;
diff --git a/src/calendar/gui/e-task-table.c b/src/calendar/gui/e-task-table.c
index 17fb1daa6d..bafb2f9c8e 100644
--- a/src/calendar/gui/e-task-table.c
+++ b/src/calendar/gui/e-task-table.c
@@ -1722,7 +1722,7 @@ hide_completed_rows_ready (GObject *source_object,
g_object_unref (comp);
}
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
if (changed) {
/* To notify about changes, because in call of
@@ -1803,7 +1803,7 @@ show_completed_rows_ready (GObject *source_object,
g_object_unref (comp);
}
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
}
/* Returns the current time, for the ECellDateEdit items.
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index 1d6c005178..5e2b88c396 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -1623,25 +1623,25 @@ comp_compliant_one (ESourceRegistry *registry,
e_cal_component_remove_all_alarms (clone);
} else {
/* Always strip procedure alarms, because of security */
- GList *uids, *l;
+ GSList *uids, *link;
uids = e_cal_component_get_alarm_uids (clone);
- for (l = uids; l; l = l->next) {
+ for (link = uids; link; link = g_slist_next (link)) {
ECalComponentAlarm *alarm;
ECalComponentAlarmAction action = E_CAL_COMPONENT_ALARM_UNKNOWN;
- alarm = e_cal_component_get_alarm (clone, (const gchar *) l->data);
+ alarm = e_cal_component_get_alarm (clone, link->data);
if (alarm) {
e_cal_component_alarm_get_action (alarm, &action);
e_cal_component_alarm_free (alarm);
if (action == E_CAL_COMPONENT_ALARM_PROCEDURE)
- e_cal_component_remove_alarm (clone, (const gchar *) l->data);
+ e_cal_component_remove_alarm (clone, link->data);
}
}
- cal_obj_uid_list_free (uids);
+ g_slist_free_full (uids, g_free);
}
strip_x_microsoft_props (clone);
diff --git a/src/modules/calendar/e-cal-shell-view-private.c b/src/modules/calendar/e-cal-shell-view-private.c
index 42a4b2712a..b691e7cfc5 100644
--- a/src/modules/calendar/e-cal-shell-view-private.c
+++ b/src/modules/calendar/e-cal-shell-view-private.c
@@ -717,9 +717,9 @@ cal_search_get_object_list_cb (GObject *source,
cal_searching_instances_done_cb);
}
- e_cal_client_free_icalcomp_slist (icalcomps);
+ e_util_free_nullable_object_slist (icalcomps);
} else {
- e_cal_client_free_icalcomp_slist (icalcomps);
+ e_util_free_nullable_object_slist (icalcomps);
}
}
diff --git a/src/modules/itip-formatter/itip-view.c b/src/modules/itip-formatter/itip-view.c
index 46178fc2d0..c215a91cc2 100644
--- a/src/modules/itip-formatter/itip-view.c
+++ b/src/modules/itip-formatter/itip-view.c
@@ -4458,7 +4458,7 @@ find_server (ItipView *view,
fd->cancelled_id = g_cancellable_connect (
fd->itip_cancellable,
G_CALLBACK (itip_cancellable_cancelled), fd->cancellable, NULL);
- fd->conflicts = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
(GDestroyNotify) e_cal_client_free_icalcomp_slist);
+ fd->conflicts = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
(GDestroyNotify) e_util_free_nullable_object_slist);
fd->uid = g_strdup (uid);
fd->rid = rid;
/* avoid free this at the end */
@@ -4977,16 +4977,17 @@ update_item (ItipView *view,
if (itip_view_get_keep_alarm_check_state (view)) {
ECalComponent *real_comp;
- GList *alarms, *l;
- ECalComponentAlarm *alarm;
real_comp = get_real_item (view);
if (real_comp != NULL) {
+ GSList *alarms, *link;
+
alarms = e_cal_component_get_alarm_uids (real_comp);
for (l = alarms; l; l = l->next) {
- alarm = e_cal_component_get_alarm (
- real_comp, (const gchar *) l->data);
+ ECalComponentAlarm *alarm;
+
+ alarm = e_cal_component_get_alarm (real_comp, link->data);
if (alarm) {
ECalComponentAlarm *aclone = e_cal_component_alarm_clone (alarm);
@@ -5000,7 +5001,7 @@ update_item (ItipView *view,
}
}
- cal_obj_uid_list_free (alarms);
+ g_slist_free_full (alarms, g_free);
g_object_unref (real_comp);
}
}
diff --git a/src/plugins/publish-calendar/publish-format-ical.c
b/src/plugins/publish-calendar/publish-format-ical.c
index ade9e59e8b..ccaf374f3d 100644
--- a/src/plugins/publish-calendar/publish-format-ical.c
+++ b/src/plugins/publish-calendar/publish-format-ical.c
@@ -132,7 +132,7 @@ write_calendar (const gchar *uid,
ical_string = icalcomponent_as_ical_string_r (top_level);
res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL,
error);
g_free (ical_string);
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
}
g_object_unref (client);
diff --git a/src/plugins/save-calendar/ical-format.c b/src/plugins/save-calendar/ical-format.c
index e42ae7f0f7..43171faf39 100644
--- a/src/plugins/save-calendar/ical-format.c
+++ b/src/plugins/save-calendar/ical-format.c
@@ -157,7 +157,7 @@ do_save_calendar_ical (FormatHandler *handler,
g_free (ical_str);
}
- e_cal_client_free_icalcomp_slist (objects);
+ e_util_free_nullable_object_slist (objects);
}
if (error != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]