[evolution] I#1942 - Calendar: Show extra Google attendee info in component preview
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1942 - Calendar: Show extra Google attendee info in component preview
- Date: Mon, 27 Jun 2022 16:19:20 +0000 (UTC)
commit 5557253687689807fbd8dbf3858b2ded03ca2c19
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 27 18:18:43 2022 +0200
I#1942 - Calendar: Show extra Google attendee info in component preview
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1942
src/calendar/gui/e-cal-component-preview.c | 61 ++++++++++++++++++++++++++++
src/calendar/importers/icalendar-importer.c | 62 ++++++++++++++++++++++++++---
2 files changed, 118 insertions(+), 5 deletions(-)
---
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index 8987abbe74..af7e5bb12d 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -452,6 +452,7 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
for (a = attendees; a; a = a->next) {
ECalComponentAttendee *attnd = a->data;
+ ECalComponentParameterBag *param_bag;
const gchar *email = cal_comp_util_get_attendee_email (attnd);
if (!attnd || !email || !*email)
@@ -490,6 +491,66 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_free (str);
}
+ param_bag = e_cal_component_attendee_get_parameter_bag (attnd);
+ if (param_bag) {
+ ICalParameter *num_guests = NULL;
+ ICalParameter *response_comment = NULL;
+ guint ii, count;
+
+ count = e_cal_component_parameter_bag_get_count (param_bag);
+ for (ii = 0; ii < count && (!num_guests || !response_comment); ii++) {
+ ICalParameter *param = e_cal_component_parameter_bag_get (param_bag,
ii);
+
+ if (param && i_cal_parameter_isa (param) == I_CAL_X_PARAMETER) {
+ const gchar *xname = i_cal_parameter_get_xname (param);
+
+ if (!xname)
+ continue;
+
+ if (!num_guests && g_ascii_strcasecmp (xname, "X-NUM-GUESTS")
== 0)
+ num_guests = param;
+
+ if (!response_comment && g_ascii_strcasecmp (xname,
"X-RESPONSE-COMMENT") == 0)
+ response_comment = param;
+ }
+ }
+
+ if (num_guests && i_cal_parameter_get_xvalue (num_guests)) {
+ gint n_guests;
+
+ n_guests = (gint) g_ascii_strtoll (i_cal_parameter_get_xvalue
(num_guests), NULL, 10);
+
+ if (n_guests > 0) {
+ gchar *str, *escaped;
+
+ str = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "with
one guest", "with %d guests", n_guests), n_guests);
+ escaped = g_markup_escape_text (str, -1);
+
+ g_string_append_c (buffer, ' ');
+ g_string_append (buffer, escaped);
+
+ g_free (escaped);
+ g_free (str);
+ }
+ }
+
+ if (response_comment) {
+ const gchar *value = i_cal_parameter_get_xvalue (response_comment);
+
+ if (value && *value) {
+ gchar *escaped;
+
+ escaped = g_markup_escape_text (value, -1);
+
+ g_string_append (buffer, " (");
+ g_string_append (buffer, escaped);
+ g_string_append_c (buffer, ')');
+
+ g_free (escaped);
+ }
+ }
+ }
+
have = TRUE;
}
diff --git a/src/calendar/importers/icalendar-importer.c b/src/calendar/importers/icalendar-importer.c
index 68b771c67f..b674e07647 100644
--- a/src/calendar/importers/icalendar-importer.c
+++ b/src/calendar/importers/icalendar-importer.c
@@ -1519,6 +1519,8 @@ preview_comp (EWebViewPreview *preview,
for (link = attendees; link; link = g_slist_next (link)) {
ECalComponentAttendee *attnd = link->data;
+ ECalComponentParameterBag *param_bag;
+ GString *str;
const gchar *value, *cn;
if (!attnd)
@@ -1530,15 +1532,65 @@ preview_comp (EWebViewPreview *preview,
cn = e_cal_component_attendee_get_cn (attnd);
+ str = g_string_new ("");
+
if (cn && *cn) {
- tmp = g_strconcat (cn, " <", strip_mailto (value), ">", NULL);
- /* Translators: Appointment's attendees */
- e_web_view_preview_add_section (preview, have ? NULL : C_("iCalImp",
"Attendees"), tmp);
- g_free (tmp);
+ g_string_append_printf (str, "%s <%s>", cn, strip_mailto (value));
} else {
- e_web_view_preview_add_section (preview, have ? NULL : C_("iCalImp",
"Attendees"), strip_mailto (value));
+ g_string_append (str, strip_mailto (value));
}
+ param_bag = e_cal_component_attendee_get_parameter_bag (attnd);
+ if (param_bag) {
+ ICalParameter *num_guests = NULL;
+ ICalParameter *response_comment = NULL;
+ guint ii, count;
+
+ count = e_cal_component_parameter_bag_get_count (param_bag);
+ for (ii = 0; ii < count && (!num_guests || !response_comment); ii++) {
+ ICalParameter *param = e_cal_component_parameter_bag_get (param_bag,
ii);
+
+ if (param && i_cal_parameter_isa (param) == I_CAL_X_PARAMETER) {
+ const gchar *xname = i_cal_parameter_get_xname (param);
+
+ if (!xname)
+ continue;
+
+ if (!num_guests && g_ascii_strcasecmp (xname, "X-NUM-GUESTS")
== 0)
+ num_guests = param;
+
+ if (!response_comment && g_ascii_strcasecmp (xname,
"X-RESPONSE-COMMENT") == 0)
+ response_comment = param;
+ }
+ }
+
+ if (num_guests && i_cal_parameter_get_xvalue (num_guests)) {
+ gint n_guests;
+
+ n_guests = (gint) g_ascii_strtoll (i_cal_parameter_get_xvalue
(num_guests), NULL, 10);
+
+ if (n_guests > 0) {
+ g_string_append_c (str, ' ');
+ g_string_append_printf (str, g_dngettext (GETTEXT_PACKAGE,
"with one guest", "with %d guests", n_guests), n_guests);
+ }
+ }
+
+ if (response_comment) {
+ const gchar *value = i_cal_parameter_get_xvalue (response_comment);
+
+ if (value && *value) {
+ g_string_append (str, " (");
+ g_string_append (str, value);
+ g_string_append_c (str, ')');
+ }
+ }
+ }
+
+ /* Translators: Appointment's attendees */
+ e_web_view_preview_add_section (preview, have ? NULL : C_("iCalImp", "Attendees"),
str->str);
+
+ g_string_free (str, TRUE);
+
have = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]