[evolution] I#1883 - Calendar: Read Organizer/Attendee EMAIL parameter
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1883 - Calendar: Read Organizer/Attendee EMAIL parameter
- Date: Wed, 27 Apr 2022 10:54:27 +0000 (UTC)
commit 27e8d96f77f5f847ee7da2d23476d7c360c5dcc1
Author: Milan Crha <mcrha redhat com>
Date: Wed Apr 27 12:53:49 2022 +0200
I#1883 - Calendar: Read Organizer/Attendee EMAIL parameter
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1883
CMakeLists.txt | 22 +++
config.h.in | 3 +
src/calendar/gui/comp-util.c | 119 +++++++++++-
src/calendar/gui/comp-util.h | 6 +
src/calendar/gui/e-cal-component-preview.c | 16 +-
src/calendar/gui/e-cal-model.c | 2 +-
src/calendar/gui/e-calendar-view.c | 4 +-
src/calendar/gui/e-comp-editor-page-general.c | 8 +-
src/calendar/gui/e-comp-editor-page-reminders.c | 7 +-
src/calendar/gui/e-comp-editor.c | 8 +-
src/calendar/gui/e-day-view.c | 11 +-
src/calendar/gui/e-meeting-attendee.c | 13 +-
src/calendar/gui/e-task-table.c | 4 +-
src/calendar/gui/e-to-do-pane.c | 3 +-
src/calendar/gui/e-week-view.c | 11 +-
src/calendar/gui/e-year-view.c | 2 +-
src/calendar/gui/itip-utils.c | 211 +++++++++++++--------
src/calendar/gui/itip-utils.h | 3 +-
src/calendar/gui/print.c | 2 +-
src/calendar/importers/icalendar-importer.c | 80 +++++++-
src/modules/calendar/e-cal-shell-content.c | 4 +-
src/modules/calendar/e-cal-shell-view-actions.c | 5 +-
.../composer-to-meeting/e-meeting-to-composer.c | 5 +-
src/modules/itip-formatter/itip-view.c | 62 +++---
src/plugins/save-calendar/csv-format.c | 2 +-
src/plugins/save-calendar/format-handler.h | 1 +
src/plugins/save-calendar/rdf-format.c | 2 +-
27 files changed, 443 insertions(+), 173 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88a67351c6..dfee8f3b3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -603,6 +603,28 @@ set(HAVE_LIBNOTIFY ${LIBNOTIFY_FOUND})
pkg_check_modules(LIBUNITY unity>=${libunity_minimum_version})
set(HAVE_LIBUNITY ${LIBUNITY_FOUND})
+# ******************************
+# libical tests
+# ******************************
+
+set(CMAKE_REQUIRED_DEFINITIONS ${EVOLUTION_DATA_SERVER_CFLAGS_OTHER})
+set(CMAKE_REQUIRED_INCLUDES ${EVOLUTION_DATA_SERVER_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${EVOLUTION_DATA_SERVER_LDFLAGS})
+
+CHECK_C_SOURCE_COMPILES("#define LIBICAL_GLIB_UNSTABLE_API 1
+ #include <libical-glib/libical-glib.h>
+ int main(void) {
+ icalparameter *param;
+ param = i_cal_property_get_first_parameter (NULL, I_CAL_EMAIL_PARAMETER);
+ i_cal_parameter_get_email (param);
+ i_cal_parameter_new_email (NULL);
+ return 0;
+ }" HAVE_I_CAL_EMAIL_PARAMETER)
+
+unset(CMAKE_REQUIRED_DEFINITIONS)
+unset(CMAKE_REQUIRED_INCLUDES)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
# ******************************
# gspell
# ******************************
diff --git a/config.h.in b/config.h.in
index 2b520a96bd..389190e09f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -122,3 +122,6 @@
/* Define if markdown support is enabled */
#cmakedefine HAVE_MARKDOWN 1
+
+/* Define if libical-glib has I_CAL_EMAIL_PARAMETER */
+#cmakedefine HAVE_I_CAL_EMAIL_PARAMETER 1
diff --git a/src/calendar/gui/comp-util.c b/src/calendar/gui/comp-util.c
index 41a71414b7..bee1120bf8 100644
--- a/src/calendar/gui/comp-util.c
+++ b/src/calendar/gui/comp-util.c
@@ -1594,7 +1594,7 @@ cal_comp_util_get_attendee_comments (ICalComponent *icomp)
guests_str = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, "with one guest", "with
%d guests", num_guests), num_guests);
if (guests_str || (value && *value)) {
- const gchar *email = i_cal_property_get_attendee (prop);
+ const gchar *email = cal_comp_util_get_property_email (prop);
const gchar *cn = NULL;
ICalParameter *cnparam;
@@ -2223,7 +2223,7 @@ cal_comp_util_dup_tooltip (ECalComponent *comp,
if (organizer && e_cal_component_organizer_get_cn (organizer)) {
const gchar *email;
- email = itip_strip_mailto (e_cal_component_organizer_get_value (organizer));
+ email = cal_comp_util_get_organizer_email (organizer);
if (email) {
/* Translators: It will display "Organizer: NameOfTheUser <email ofuser com>" */
@@ -2413,3 +2413,118 @@ cal_comp_util_dup_tooltip (ECalComponent *comp,
return g_string_free (tooltip, FALSE);
}
+
+const gchar *
+cal_comp_util_get_property_email (ICalProperty *prop)
+{
+ ICalParameter *param;
+ const gchar *email = NULL;
+
+ if (!prop)
+ return NULL;
+
+ #ifdef HAVE_I_CAL_EMAIL_PARAMETER
+ param = i_cal_property_get_first_parameter (prop, I_CAL_EMAIL_PARAMETER);
+
+ if (param) {
+ email = i_cal_parameter_get_email (param);
+ if (email)
+ email = itip_strip_mailto (email);
+
+ g_clear_object (¶m);
+ }
+ #else
+ param = i_cal_property_get_first_parameter (prop, (ICalParameterKind) ICAL_EMAIL_PARAMETER);
+
+ if (param) {
+ email = icalparameter_get_email (i_cal_object_get_native (I_CAL_OBJECT (param)));
+ if (email)
+ email = itip_strip_mailto (email);
+
+ g_clear_object (¶m);
+ }
+ #endif /* HAVE_I_CAL_EMAIL_PARAMETER */
+
+ if (!email || !*email) {
+ if (i_cal_property_isa (prop) == I_CAL_ORGANIZER_PROPERTY)
+ email = i_cal_property_get_organizer (prop);
+ else if (i_cal_property_isa (prop) == I_CAL_ATTENDEE_PROPERTY)
+ email = i_cal_property_get_attendee (prop);
+ else
+ g_warn_if_reached ();
+
+ email = itip_strip_mailto (email);
+ }
+
+ if (email && !*email)
+ email = NULL;
+
+ return email;
+}
+
+static const gchar *
+cal_comp_util_get_property_value_email (const gchar *value,
+ ECalComponentParameterBag *params)
+{
+ const gchar *address = NULL;
+
+ if (params) {
+ guint email_index;
+
+ #ifdef HAVE_I_CAL_EMAIL_PARAMETER
+ email_index = e_cal_component_parameter_bag_get_first_by_kind (params, I_CAL_EMAIL_PARAMETER);
+ #else
+ email_index = e_cal_component_parameter_bag_get_first_by_kind (params, (ICalParameterKind)
ICAL_EMAIL_PARAMETER);
+ #endif
+
+ if (email_index < e_cal_component_parameter_bag_get_count (params)) {
+ ICalParameter *param;
+
+ param = e_cal_component_parameter_bag_get (params, email_index);
+
+ if (param) {
+ #ifdef HAVE_I_CAL_EMAIL_PARAMETER
+ address = i_cal_parameter_get_email (param);
+ #else
+ address = icalparameter_get_email (i_cal_object_get_native (I_CAL_OBJECT
(param)));
+ #endif
+
+ if (address && !*address)
+ address = NULL;
+ }
+ }
+ }
+
+ if (!address)
+ address = value;
+
+ if (address)
+ address = itip_strip_mailto (address);
+
+ if (address && !*address)
+ address = NULL;
+
+ return address;
+}
+
+const gchar *
+cal_comp_util_get_organizer_email (const ECalComponentOrganizer *organizer)
+{
+ if (!organizer)
+ return NULL;
+
+ return cal_comp_util_get_property_value_email (
+ e_cal_component_organizer_get_value (organizer),
+ e_cal_component_organizer_get_parameter_bag (organizer));
+}
+
+const gchar *
+cal_comp_util_get_attendee_email (const ECalComponentAttendee *attendee)
+{
+ if (!attendee)
+ return NULL;
+
+ return cal_comp_util_get_property_value_email (
+ e_cal_component_attendee_get_value (attendee),
+ e_cal_component_attendee_get_parameter_bag (attendee));
+}
diff --git a/src/calendar/gui/comp-util.h b/src/calendar/gui/comp-util.h
index 3eab0c4309..322f2da6cd 100644
--- a/src/calendar/gui/comp-util.h
+++ b/src/calendar/gui/comp-util.h
@@ -212,5 +212,11 @@ gchar * cal_comp_util_dup_tooltip (ECalComponent *comp,
ECalClient *client,
ESourceRegistry *registry,
ICalTimezone *default_zone);
+const gchar * cal_comp_util_get_property_email
+ (ICalProperty *prop);
+const gchar * cal_comp_util_get_organizer_email
+ (const ECalComponentOrganizer *organizer);
+const gchar * cal_comp_util_get_attendee_email
+ (const ECalComponentAttendee *attendee);
#endif
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index e9980fc887..1b5ed7269f 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -410,20 +410,19 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
if (e_cal_component_has_organizer (comp)) {
ECalComponentOrganizer *organizer;
+ const gchar *organizer_email;
organizer = e_cal_component_get_organizer (comp);
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
- if (organizer && e_cal_component_organizer_get_value (organizer) &&
e_cal_component_organizer_get_value (organizer)[0]) {
- const gchar *email = itip_strip_mailto (e_cal_component_organizer_get_value
(organizer));
- if (!email)
- email = "";
+ if (organizer_email) {
markup = g_markup_escape_text (_("Organizer:"), -1);
g_string_append_printf (buffer, "<tr><th>%s</th>", markup);
g_free (markup);
if (e_cal_component_organizer_get_cn (organizer) && e_cal_component_organizer_get_cn
(organizer)[0]) {
gchar *html;
- str = g_strconcat (e_cal_component_organizer_get_cn (organizer), " <", email,
">", NULL);
+ str = g_strconcat (e_cal_component_organizer_get_cn (organizer), " <",
organizer_email, ">", NULL);
html = camel_text_to_html (str,
CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
@@ -432,7 +431,7 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_free (html);
g_free (str);
} else {
- str = camel_text_to_html (email,
+ str = camel_text_to_html (organizer_email,
CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0);
@@ -452,9 +451,9 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
for (a = attendees; a; a = a->next) {
ECalComponentAttendee *attnd = a->data;
- const gchar *email;
+ const gchar *email = cal_comp_util_get_attendee_email (attnd);
- if (!attnd || !e_cal_component_attendee_get_value (attnd) ||
!e_cal_component_attendee_get_value (attnd)[0])
+ if (!attnd || !email || !*email)
continue;
if (!have) {
@@ -465,7 +464,6 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
g_string_append (buffer, "<br>");
}
- email = itip_strip_mailto (e_cal_component_attendee_get_value (attnd));
if (!email)
email = "";
diff --git a/src/calendar/gui/e-cal-model.c b/src/calendar/gui/e-cal-model.c
index 99f10685bb..c392cf3fdf 100644
--- a/src/calendar/gui/e-cal-model.c
+++ b/src/calendar/gui/e-cal-model.c
@@ -1606,7 +1606,7 @@ cal_model_value_at (ETableModel *etm,
ECalComponentAttendee *ca = sl->data;
const gchar *text;
- text = itip_strip_mailto (e_cal_component_attendee_get_value
(ca));
+ text = cal_comp_util_get_attendee_email (ca);
if (itip_address_is_user (registry, text)) {
if (e_cal_component_attendee_get_delegatedto (ca) !=
NULL)
retval = 3;
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index e1be54f174..529e6306b4 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -165,11 +165,11 @@ calendar_view_check_for_retract (ECalComponent *comp,
if (!organizer)
return FALSE;
- strip = itip_strip_mailto (e_cal_component_organizer_get_value (organizer));
+ strip = cal_comp_util_get_organizer_email (organizer);
ret_val =
e_client_get_backend_property_sync (E_CLIENT (client),
E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS, &email, NULL, NULL) &&
- (g_ascii_strcasecmp (email, strip) == 0);
+ itip_email_addresses_equal (email, strip);
g_free (email);
diff --git a/src/calendar/gui/e-comp-editor-page-general.c b/src/calendar/gui/e-comp-editor-page-general.c
index 06ae734e86..13b092eef9 100644
--- a/src/calendar/gui/e-comp-editor-page-general.c
+++ b/src/calendar/gui/e-comp-editor-page-general.c
@@ -326,7 +326,7 @@ ecep_general_attendees_remove_clicked_cb (GtkButton *button,
errors = g_string_new ("");
else
g_string_append_c (errors, '\n');
- g_string_append_printf (errors, _("Not enough rights to delete attendee ā%sā"),
e_meeting_attendee_get_address (attendee));
+ g_string_append_printf (errors, _("Not enough rights to delete attendee ā%sā"),
itip_strip_mailto (e_meeting_attendee_get_address (attendee)));
failures++;
} else {
ecep_general_remove_attendee (page_general, attendee);
@@ -885,7 +885,7 @@ ecep_general_fill_widgets (ECompEditorPage *page,
g_object_unref (prop), prop = i_cal_component_get_next_property (component,
I_CAL_ATTENDEE_PROPERTY)) {
const gchar *address;
- address = itip_strip_mailto (i_cal_property_get_attendee (prop));
+ address = cal_comp_util_get_property_email (prop);
if (address)
page_general->priv->orig_attendees = g_slist_prepend
(page_general->priv->orig_attendees, g_strdup (address));
}
@@ -897,7 +897,7 @@ ecep_general_fill_widgets (ECompEditorPage *page,
ICalParameter *param;
const gchar *organizer;
- organizer = i_cal_property_get_organizer (prop);
+ organizer = cal_comp_util_get_property_email (prop);
if (organizer && *organizer) {
ECompEditor *comp_editor;
@@ -973,7 +973,7 @@ ecep_general_fill_widgets (ECompEditorPage *page,
g_object_unref (prop), prop = i_cal_component_get_next_property (component,
I_CAL_ATTENDEE_PROPERTY)) {
const gchar *address;
- address = itip_strip_mailto (i_cal_property_get_attendee (prop));
+ address = cal_comp_util_get_property_email (prop);
if (address) {
EMeetingAttendee *attendee;
ECalComponentAttendee *comp_attendee;
diff --git a/src/calendar/gui/e-comp-editor-page-reminders.c b/src/calendar/gui/e-comp-editor-page-reminders.c
index d1991f96bf..0241c20c97 100644
--- a/src/calendar/gui/e-comp-editor-page-reminders.c
+++ b/src/calendar/gui/e-comp-editor-page-reminders.c
@@ -31,6 +31,7 @@
#include <e-util/e-util.h>
#include "calendar-config.h"
+#include "comp-util.h"
#include "e-alarm-list.h"
#include "itip-utils.h"
@@ -580,14 +581,16 @@ ecep_reminders_selected_to_widgets (ECompEditorPageReminders *page_reminders)
for (link = attendees; link; link = g_slist_next (link)) {
ECalComponentAttendee *att = link->data;
EDestination *dest;
+ const gchar *att_email;
dest = e_destination_new ();
if (att && e_cal_component_attendee_get_cn (att) && e_cal_component_attendee_get_cn
(att)[0])
e_destination_set_name (dest, e_cal_component_attendee_get_cn (att));
- if (att && e_cal_component_attendee_get_value (att) &&
e_cal_component_attendee_get_value (att)[0])
- e_destination_set_email (dest, itip_strip_mailto
(e_cal_component_attendee_get_value (att)));
+ att_email = cal_comp_util_get_attendee_email (att);
+ if (att_email)
+ e_destination_set_email (dest, att_email);
e_destination_store_append_destination (destination_store, dest);
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index c6506e0707..7ad485ccc2 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -168,15 +168,15 @@ ece_set_attendees_for_delegation (ECalComponent *comp,
prop;
g_object_unref (prop), prop = again ? i_cal_component_get_first_property (icomp,
I_CAL_ATTENDEE_PROPERTY) :
i_cal_component_get_next_property (icomp, I_CAL_ATTENDEE_PROPERTY)) {
- const gchar *attendee = i_cal_property_get_attendee (prop);
+ const gchar *attendee = cal_comp_util_get_property_email (prop);
const gchar *delfrom = NULL;
again = FALSE;
param = i_cal_property_get_first_parameter (prop, I_CAL_DELEGATEDFROM_PARAMETER);
if (param)
delfrom = i_cal_parameter_get_delegatedfrom (param);
- if (!(g_str_equal (itip_strip_mailto (attendee), address) ||
- ((delfrom && *delfrom) && g_str_equal (itip_strip_mailto (delfrom), address)))) {
+ if (!(itip_email_addresses_equal (attendee, address) ||
+ ((delfrom && *delfrom) && itip_email_addresses_equal (delfrom, address)))) {
i_cal_component_remove_property (icomp, prop);
again = TRUE;
}
@@ -1540,7 +1540,7 @@ ece_organizer_is_user (ECompEditor *comp_editor,
return FALSE;
}
- organizer = itip_strip_mailto (i_cal_property_get_organizer (prop));
+ organizer = cal_comp_util_get_property_email (prop);
if (!organizer || !*organizer) {
g_clear_object (&prop);
return FALSE;
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index 0c08867ad7..7550dec93a 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -3415,16 +3415,11 @@ set_style_from_attendee (EDayViewEvent *event,
ECalComponentAttendee *attendee = l->data;
const gchar *value, *sentby;
- value = e_cal_component_attendee_get_value (attendee);
- if (value)
- value = itip_strip_mailto (value);
-
+ value = cal_comp_util_get_attendee_email (attendee);
sentby = e_cal_component_attendee_get_sentby (attendee);
- if (sentby)
- value = itip_strip_mailto (sentby);
- if ((value && g_ascii_strcasecmp (value, address) == 0) ||
- (sentby && g_ascii_strcasecmp (sentby, address) == 0)) {
+ if (itip_email_addresses_equal (value, address) ||
+ itip_email_addresses_equal (sentby, address)) {
partstat = e_cal_component_attendee_get_partstat (attendee);
break;
}
diff --git a/src/calendar/gui/e-meeting-attendee.c b/src/calendar/gui/e-meeting-attendee.c
index 02a62d09f0..3007fccfb9 100644
--- a/src/calendar/gui/e-meeting-attendee.c
+++ b/src/calendar/gui/e-meeting-attendee.c
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <gtk/gtk.h>
+
+#include "comp-util.h"
#include "e-meeting-utils.h"
#include "e-meeting-attendee.h"
@@ -236,7 +238,7 @@ e_meeting_attendee_new_from_e_cal_component_attendee (const ECalComponentAttende
ia = E_MEETING_ATTENDEE (g_object_new (E_TYPE_MEETING_ATTENDEE, NULL));
- e_meeting_attendee_set_address (ia, e_cal_component_attendee_get_value (ca));
+ e_meeting_attendee_set_address (ia, cal_comp_util_get_attendee_email (ca));
e_meeting_attendee_set_member (ia, e_cal_component_attendee_get_member (ca));
e_meeting_attendee_set_cutype (ia, e_cal_component_attendee_get_cutype (ca));
e_meeting_attendee_set_role (ia, e_cal_component_attendee_get_role (ca));
@@ -310,7 +312,14 @@ e_meeting_attendee_set_address (EMeetingAttendee *ia,
{
g_return_if_fail (E_IS_MEETING_ATTENDEE (ia));
- set_string_value (ia, &ia->priv->address, address);
+ if (address && *address && g_ascii_strncasecmp (address, "mailto:", 7) != 0) {
+ /* Always with mailto: prefix */
+ gchar *tmp = g_strconcat ("mailto:", address, NULL);
+ set_string_value (ia, &ia->priv->address, tmp);
+ g_free (tmp);
+ } else {
+ set_string_value (ia, &ia->priv->address, address);
+ }
}
gboolean
diff --git a/src/calendar/gui/e-task-table.c b/src/calendar/gui/e-task-table.c
index f5c35d2bf2..de3d39e829 100644
--- a/src/calendar/gui/e-task-table.c
+++ b/src/calendar/gui/e-task-table.c
@@ -1071,7 +1071,7 @@ check_for_retract (ECalComponent *comp,
return FALSE;
org = e_cal_component_get_organizer (comp);
- strip = org ? itip_strip_mailto (e_cal_component_organizer_get_value (org)) : NULL;
+ strip = cal_comp_util_get_organizer_email (org);
if (!strip || !*strip) {
e_cal_component_organizer_free (org);
@@ -1082,7 +1082,7 @@ check_for_retract (ECalComponent *comp,
E_CLIENT (client),
E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS,
&email, NULL, NULL) && email != NULL &&
- g_ascii_strcasecmp (email, strip) == 0;
+ itip_email_addresses_equal (email, strip);
e_cal_component_organizer_free (org);
g_free (email);
diff --git a/src/calendar/gui/e-to-do-pane.c b/src/calendar/gui/e-to-do-pane.c
index 852668e417..788fdf7e4d 100644
--- a/src/calendar/gui/e-to-do-pane.c
+++ b/src/calendar/gui/e-to-do-pane.c
@@ -24,6 +24,7 @@
#include <libedataserverui/libedataserverui.h>
#include <libecal/libecal.h>
+#include "comp-util.h"
#include "e-cal-data-model.h"
#include "e-cal-data-model-subscriber.h"
#include "e-cal-dialogs.h"
@@ -1032,7 +1033,7 @@ etdp_add_component (EToDoPane *to_do_pane,
ECalComponentAttendee *ca = link->data;
const gchar *text;
- text = itip_strip_mailto (e_cal_component_attendee_get_value (ca));
+ text = cal_comp_util_get_attendee_email (ca);
if (itip_address_is_user (registry, text)) {
if (e_cal_component_attendee_get_delegatedto (ca))
icon_name = "stock_task-assigned-to";
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 499fdad1a6..ce6840866e 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -2750,14 +2750,11 @@ set_style_from_attendee (EWeekViewEvent *event,
if (!attendee)
continue;
- value = e_cal_component_attendee_get_value (attendee);
- if (value)
- value = itip_strip_mailto (value);
+ value = cal_comp_util_get_attendee_email (attendee);
sentby = e_cal_component_attendee_get_sentby (attendee);
- if (sentby)
- sentby = itip_strip_mailto (sentby);
- if ((value && g_ascii_strcasecmp (value, address) == 0) ||
- (sentby && g_ascii_strcasecmp (sentby, address) == 0)) {
+
+ if (itip_email_addresses_equal (value, address) ||
+ itip_email_addresses_equal (sentby, address)) {
partstat = e_cal_component_attendee_get_partstat (attendee);
break;
}
diff --git a/src/calendar/gui/e-year-view.c b/src/calendar/gui/e-year-view.c
index 4d96177360..5b076767fb 100644
--- a/src/calendar/gui/e-year-view.c
+++ b/src/calendar/gui/e-year-view.c
@@ -427,7 +427,7 @@ year_view_get_component_icon_name (EYearView *self,
ECalComponentAttendee *ca = link->data;
const gchar *text;
- text = itip_strip_mailto (e_cal_component_attendee_get_value (ca));
+ text = cal_comp_util_get_attendee_email (ca);
if (itip_address_is_user (registry, text)) {
if (e_cal_component_attendee_get_delegatedto (ca))
icon_name = "stock_task-assigned-to";
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index eb7390659b..969f1e7f47 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -42,6 +42,36 @@
#define d(x)
+/**
+ * itip_email_addresses_equal:
+ * @email1: (nullable): the first email
+ * @email2: (nullable): the second email
+ *
+ * Compares two email addresses and returns whether they are equal.
+ * Each address can contain a "mailto:" prefix. The two addresses
+ * match only if they are non-NULL and non-empty. The address itself
+ * is compared case insensitively.
+ *
+ * Returns: %TRUE, when the @email1 equals to @email2
+ *
+ * Since: 3.46
+ **/
+gboolean
+itip_email_addresses_equal (const gchar *email1,
+ const gchar *email2)
+{
+ if (!email1 || !email2)
+ return FALSE;
+
+ email1 = itip_strip_mailto (email1);
+ email2 = itip_strip_mailto (email2);
+
+ if (!email1 || !*email1 || !email2 || !*email2)
+ return FALSE;
+
+ return g_ascii_strcasecmp (email1, email2) == 0;
+}
+
/**
* itip_get_default_name_and_address:
* @registry: an #ESourceRegistry
@@ -301,15 +331,15 @@ itip_organizer_is_user_ex (ESourceRegistry *registry,
return FALSE;
organizer = e_cal_component_get_organizer (comp);
- if (organizer && e_cal_component_organizer_get_value (organizer)) {
+ if (organizer) {
gchar *email = NULL;
- strip = itip_strip_mailto (e_cal_component_organizer_get_value (organizer));
+ strip = cal_comp_util_get_organizer_email (organizer);
if (e_client_get_backend_property_sync (E_CLIENT (cal_client),
E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS,
&email, NULL, NULL) &&
- email && g_ascii_strcasecmp (email, strip) == 0) {
+ email && itip_email_addresses_equal (email, strip)) {
e_cal_component_organizer_free (organizer);
g_free (email);
@@ -364,6 +394,8 @@ itip_has_any_attendees (ECalComponent *comp)
ECalComponentOrganizer *organizer;
ECalComponentAttendee *attendee;
GSList *attendees = NULL;
+ const gchar *organizer_email;
+ const gchar *attendee_email;
gboolean res;
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
@@ -395,9 +427,11 @@ itip_has_any_attendees (ECalComponent *comp)
organizer = e_cal_component_get_organizer (comp);
- res = e_cal_component_attendee_get_value (attendee) && (!organizer ||
!e_cal_component_organizer_get_value (organizer) ||
- g_ascii_strcasecmp (itip_strip_mailto (e_cal_component_attendee_get_value (attendee)),
- itip_strip_mailto (e_cal_component_organizer_get_value (organizer))) != 0);
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+ attendee_email = cal_comp_util_get_attendee_email (attendee);
+
+ res = attendee_email && (!organizer_email ||
+ !itip_email_addresses_equal (attendee_email, organizer_email));
g_slist_free_full (attendees, e_cal_component_attendee_free);
e_cal_component_organizer_free (organizer);
@@ -419,11 +453,12 @@ get_attendee (GSList *attendees,
ECalComponentAttendee *attendee = l->data;
const gchar *nomailto;
- nomailto = itip_strip_mailto (e_cal_component_attendee_get_value (attendee));
+ nomailto = cal_comp_util_get_attendee_email (attendee);
+
if (!nomailto || !*nomailto)
continue;
- if ((address && g_ascii_strcasecmp (nomailto, address) == 0) ||
+ if ((address && itip_email_addresses_equal (nomailto, address)) ||
(aliases && g_hash_table_contains (aliases, nomailto))) {
return attendee;
}
@@ -447,7 +482,7 @@ get_attendee_if_attendee_sentby_is_user (GSList *attendees,
if (!nomailto || !*nomailto)
continue;
- if ((address && g_ascii_strcasecmp (nomailto, address) == 0) ||
+ if ((address && itip_email_addresses_equal (nomailto, address)) ||
(aliases && g_hash_table_contains (aliases, nomailto))) {
return attendee;
}
@@ -594,7 +629,7 @@ itip_get_comp_attendee (ESourceRegistry *registry,
if (attendee) {
gchar *user_email;
- user_email = g_strdup (itip_strip_mailto (e_cal_component_attendee_get_value
(attendee)));
+ user_email = g_strdup (cal_comp_util_get_attendee_email (attendee));
g_slist_free_full (attendees, e_cal_component_attendee_free);
g_free (address);
@@ -637,7 +672,7 @@ itip_get_comp_attendee (ESourceRegistry *registry,
if (attendee != NULL) {
gchar *user_email;
- user_email = g_strdup (itip_strip_mailto (e_cal_component_attendee_get_value
(attendee)));
+ user_email = g_strdup (cal_comp_util_get_attendee_email (attendee));
g_slist_free_full (attendees, e_cal_component_attendee_free);
if (aliases)
@@ -869,7 +904,7 @@ users_has_attendee (const GSList *users,
const GSList *l;
for (l = users; l != NULL; l = l->next) {
- if (!g_ascii_strcasecmp (address, l->data))
+ if (itip_email_addresses_equal (address, l->data))
return TRUE;
}
@@ -885,6 +920,7 @@ comp_from (ICalPropertyMethod method,
ECalComponentOrganizer *organizer;
ECalComponentAttendee *attendee;
GSList *attendees;
+ const gchar *email_address;
gchar *from;
gchar *sender = NULL;
@@ -907,7 +943,9 @@ comp_from (ICalPropertyMethod method,
case I_CAL_METHOD_ADD:
organizer = e_cal_component_get_organizer (comp);
- if (!organizer || !e_cal_component_organizer_get_value (organizer)) {
+ email_address = cal_comp_util_get_organizer_email (organizer);
+
+ if (!email_address) {
e_cal_component_organizer_free (organizer);
e_notice (
NULL, GTK_MESSAGE_ERROR,
@@ -916,7 +954,7 @@ comp_from (ICalPropertyMethod method,
}
if (from_name)
*from_name = g_strdup (e_cal_component_organizer_get_cn (organizer));
- from = g_strdup (itip_strip_mailto (e_cal_component_organizer_get_value (organizer)));
+ from = g_strdup (email_address);
e_cal_component_organizer_free (organizer);
return from;
@@ -926,8 +964,10 @@ comp_from (ICalPropertyMethod method,
return NULL;
attendee = attendees->data;
- if (e_cal_component_attendee_get_value (attendee)) {
- from = g_strdup (itip_strip_mailto (e_cal_component_attendee_get_value (attendee)));
+ email_address = cal_comp_util_get_attendee_email (attendee);
+
+ if (email_address) {
+ from = g_strdup (email_address);
if (from_name)
*from_name = g_strdup (e_cal_component_attendee_get_cn (attendee));
} else
@@ -952,6 +992,8 @@ comp_to_list (ESourceRegistry *registry,
EDestination *destination;
gint len;
gchar *sender = NULL;
+ const gchar *organizer_email;
+ const gchar *attendee_email;
union {
gpointer *pdata;
@@ -972,7 +1014,9 @@ comp_to_list (ESourceRegistry *registry,
}
organizer = e_cal_component_get_organizer (comp);
- if (!organizer || !e_cal_component_organizer_get_value (organizer)) {
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+
+ if (!organizer_email) {
g_slist_free_full (attendees, e_cal_component_attendee_free);
e_cal_component_organizer_free (organizer);
e_notice (
@@ -989,7 +1033,9 @@ comp_to_list (ESourceRegistry *registry,
ECalComponentAttendee *att = l->data;
ICalParameterCutype cutype;
- if (!e_cal_component_attendee_get_value (att))
+ attendee_email = cal_comp_util_get_attendee_email (att);
+
+ if (!attendee_email)
continue;
cutype = e_cal_component_attendee_get_cutype (att);
@@ -1005,18 +1051,18 @@ comp_to_list (ESourceRegistry *registry,
cutype != I_CAL_CUTYPE_RESOURCE &&
cutype != I_CAL_CUTYPE_UNKNOWN)
continue;
- else if (users_has_attendee (users, e_cal_component_attendee_get_value (att)))
+ else if (users_has_attendee (users, attendee_email))
continue;
else if (e_cal_component_attendee_get_sentby (att) &&
users_has_attendee (users, e_cal_component_attendee_get_sentby (att)))
continue;
- else if (!g_ascii_strcasecmp (e_cal_component_attendee_get_value (att),
e_cal_component_organizer_get_value (organizer)))
+ else if (itip_email_addresses_equal (attendee_email, organizer_email))
continue;
else if (e_cal_component_attendee_get_sentby (att) &&
e_cal_component_organizer_get_sentby (organizer) &&
- !g_ascii_strcasecmp (e_cal_component_attendee_get_sentby (att),
e_cal_component_organizer_get_sentby (organizer)))
+ itip_email_addresses_equal (e_cal_component_attendee_get_sentby (att),
e_cal_component_organizer_get_sentby (organizer)))
continue;
- else if (!g_ascii_strcasecmp (itip_strip_mailto (e_cal_component_attendee_get_value
(att)), sender))
+ else if (itip_email_addresses_equal (attendee_email, sender))
continue;
else if (e_cal_component_attendee_get_partstat (att) == I_CAL_PARTSTAT_DELEGATED &&
!e_cal_component_attendee_get_rsvp (att) &&
@@ -1027,13 +1073,13 @@ comp_to_list (ESourceRegistry *registry,
if (delegatedto && *delegatedto)
continue;
} else if (only_attendees &&
- !cal_comp_util_have_in_new_attendees (only_attendees, itip_strip_mailto
(e_cal_component_attendee_get_value (att))))
+ !cal_comp_util_have_in_new_attendees (only_attendees, attendee_email))
continue;
destination = e_destination_new ();
if (e_cal_component_attendee_get_cn (att))
e_destination_set_name (destination, e_cal_component_attendee_get_cn (att));
- e_destination_set_email (destination, itip_strip_mailto
(e_cal_component_attendee_get_value (att)));
+ e_destination_set_email (destination, attendee_email);
g_ptr_array_add (array, destination);
}
g_free (sender);
@@ -1055,12 +1101,12 @@ comp_to_list (ESourceRegistry *registry,
sender = itip_get_comp_attendee (registry, comp, NULL);
organizer = e_cal_component_get_organizer (comp);
- if (organizer && e_cal_component_organizer_get_value (organizer) &&
- (!sender || g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_organizer_get_value (organizer)), sender) != 0)) {
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+
+ if (organizer_email &&
+ (!sender || !itip_email_addresses_equal (organizer_email, sender))) {
destination = e_destination_new ();
- e_destination_set_email (
- destination,
- itip_strip_mailto (e_cal_component_organizer_get_value (organizer)));
+ e_destination_set_email (destination, organizer_email);
if (e_cal_component_organizer_get_cn (organizer))
e_destination_set_name (destination, e_cal_component_organizer_get_cn
(organizer));
g_ptr_array_add (array, destination);
@@ -1070,7 +1116,9 @@ comp_to_list (ESourceRegistry *registry,
ECalComponentAttendee *att = l->data;
ICalParameterCutype cutype;
- if (!e_cal_component_attendee_get_value (att))
+ attendee_email = cal_comp_util_get_attendee_email (att);
+
+ if (!attendee_email)
continue;
cutype = e_cal_component_attendee_get_cutype (att);
@@ -1080,20 +1128,18 @@ comp_to_list (ESourceRegistry *registry,
cutype != I_CAL_CUTYPE_UNKNOWN)
continue;
else if (only_attendees &&
- !cal_comp_util_have_in_new_attendees (only_attendees,
- itip_strip_mailto (e_cal_component_attendee_get_value (att))))
+ !cal_comp_util_have_in_new_attendees (only_attendees, attendee_email))
continue;
- else if (e_cal_component_organizer_get_value (organizer) &&
- g_ascii_strcasecmp (e_cal_component_attendee_get_value (att),
e_cal_component_organizer_get_value (organizer)) == 0)
+ else if (organizer_email &&
+ itip_email_addresses_equal (attendee_email, organizer_email))
continue;
- else if (sender && g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_attendee_get_value (att)), sender) == 0)
+ else if (sender && itip_email_addresses_equal (attendee_email, sender))
continue;
destination = e_destination_new ();
if (e_cal_component_attendee_get_cn (att))
e_destination_set_name (destination, e_cal_component_attendee_get_cn
(att));
- e_destination_set_email (
- destination, itip_strip_mailto (e_cal_component_attendee_get_value
(att)));
+ e_destination_set_email (destination, attendee_email);
g_ptr_array_add (array, destination);
}
@@ -1106,11 +1152,11 @@ comp_to_list (ESourceRegistry *registry,
destination = e_destination_new ();
organizer = e_cal_component_get_organizer (comp);
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
if (organizer && e_cal_component_organizer_get_cn (organizer))
e_destination_set_name (destination, e_cal_component_organizer_get_cn
(organizer));
- if (e_cal_component_organizer_get_value (organizer))
- e_destination_set_email (
- destination, itip_strip_mailto (e_cal_component_organizer_get_value
(organizer)));
+ if (organizer_email)
+ e_destination_set_email (destination, organizer_email);
g_ptr_array_add (array, destination);
e_cal_component_organizer_free (organizer);
@@ -1122,7 +1168,9 @@ comp_to_list (ESourceRegistry *registry,
case I_CAL_METHOD_COUNTER:
case I_CAL_METHOD_DECLINECOUNTER:
organizer = e_cal_component_get_organizer (comp);
- if (!organizer || !e_cal_component_organizer_get_value (organizer)) {
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+
+ if (!organizer_email) {
e_cal_component_organizer_free (organizer);
e_notice (
NULL, GTK_MESSAGE_ERROR,
@@ -1135,8 +1183,7 @@ comp_to_list (ESourceRegistry *registry,
destination = e_destination_new ();
if (e_cal_component_organizer_get_cn (organizer))
e_destination_set_name (destination, e_cal_component_organizer_get_cn (organizer));
- e_destination_set_email (
- destination, itip_strip_mailto (e_cal_component_organizer_get_value (organizer)));
+ e_destination_set_email (destination, organizer_email);
g_ptr_array_add (array, destination);
/* send the status to delegatee to the delegate also*/
@@ -1147,7 +1194,9 @@ comp_to_list (ESourceRegistry *registry,
ECalComponentAttendee *att = l->data;
ICalParameterCutype cutype;
- if (!e_cal_component_attendee_get_value (att))
+ attendee_email = cal_comp_util_get_attendee_email (att);
+
+ if (!attendee_email)
continue;
cutype = e_cal_component_attendee_get_cutype (att);
@@ -1158,9 +1207,9 @@ comp_to_list (ESourceRegistry *registry,
continue;
if (sender && (
- !g_ascii_strcasecmp (itip_strip_mailto (e_cal_component_attendee_get_value
(att)), sender) ||
+ itip_email_addresses_equal (attendee_email, sender) ||
(e_cal_component_attendee_get_sentby (att) &&
- !g_ascii_strcasecmp (itip_strip_mailto (e_cal_component_attendee_get_sentby
(att)), sender)))) {
+ itip_email_addresses_equal (itip_strip_mailto
(e_cal_component_attendee_get_sentby (att)), sender)))) {
const gchar *delegatedfrom;
delegatedfrom = e_cal_component_attendee_get_delegatedfrom (att);
@@ -1257,12 +1306,12 @@ comp_subject (ESourceRegistry *registry,
const gchar *value, *sentby;
a = l->data;
- value = e_cal_component_attendee_get_value (a);
+ value = cal_comp_util_get_attendee_email (a);
sentby = e_cal_component_attendee_get_sentby (a);
if ((sender && *sender) && (
- (value && !g_ascii_strcasecmp (itip_strip_mailto (value), sender)) ||
- (sentby && !g_ascii_strcasecmp (itip_strip_mailto (sentby), sender))))
+ (value && itip_email_addresses_equal (value, sender)) ||
+ (sentby && itip_email_addresses_equal (sentby, sender))))
break;
}
g_free (sender);
@@ -1539,6 +1588,7 @@ comp_sentby (ECalComponent *comp,
{
ECalComponentOrganizer *organizer;
GSList * attendees, *l;
+ const gchar *organizer_email;
gchar *name = NULL;
gchar *address = NULL;
gchar *user;
@@ -1546,7 +1596,9 @@ comp_sentby (ECalComponent *comp,
itip_get_default_name_and_address (registry, &name, &address);
organizer = e_cal_component_get_organizer (comp);
- if ((!organizer || !e_cal_component_organizer_get_value (organizer)) && name != NULL && address !=
NULL) {
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+
+ if (!organizer_email && name != NULL && address != NULL) {
gchar *tmp;
e_cal_component_organizer_free (organizer);
@@ -1573,15 +1625,14 @@ comp_sentby (ECalComponent *comp,
if (!a)
continue;
- value = e_cal_component_attendee_get_value (a);
- if (value)
- value = itip_strip_mailto (value);
+ value = cal_comp_util_get_attendee_email (a);
+
sentby = e_cal_component_attendee_get_sentby (a);
if (sentby)
sentby = itip_strip_mailto (sentby);
- if ((value && !g_ascii_strcasecmp (value, user)) ||
- (sentby && !g_ascii_strcasecmp (sentby, user))) {
+ if ((value && itip_email_addresses_equal (value, user)) ||
+ (sentby && itip_email_addresses_equal (sentby, user))) {
g_slist_free_full (attendees, e_cal_component_attendee_free);
e_cal_component_organizer_free (organizer);
g_free (user);
@@ -1601,11 +1652,9 @@ comp_sentby (ECalComponent *comp,
gchar *sentby;
sentby = g_strdup_printf ("mailto:%s", address);
- sentbyorg = e_cal_component_organizer_new_full (
- e_cal_component_organizer_get_value (organizer),
- sentby,
- e_cal_component_organizer_get_cn (organizer),
- e_cal_component_organizer_get_language (organizer));
+ sentbyorg = e_cal_component_organizer_copy (organizer);
+
+ e_cal_component_organizer_set_sentby (sentbyorg, sentby);
e_cal_component_set_organizer (comp, sentbyorg);
@@ -1630,6 +1679,7 @@ comp_minimal (ESourceRegistry *registry,
ICalProperty *prop;
ICalTime *itt;
const gchar *uid;
+ const gchar *organizer_email;
GSList *comments;
clone = e_cal_component_new ();
@@ -1656,7 +1706,8 @@ comp_minimal (ESourceRegistry *registry,
g_clear_object (&itt);
organizer = e_cal_component_get_organizer (comp);
- if (!organizer || !e_cal_component_organizer_get_value (organizer)) {
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+ if (!organizer_email) {
e_cal_component_organizer_free (organizer);
goto error;
}
@@ -2012,7 +2063,7 @@ find_enabled_identity (ESourceRegistry *registry,
extension = e_source_get_extension (source, extension_name);
address = e_source_mail_identity_get_address (extension);
- if (address && g_ascii_strcasecmp (address, id_address) == 0) {
+ if (address && itip_email_addresses_equal (address, id_address)) {
mail_identity = g_object_ref (source);
break;
}
@@ -2052,18 +2103,18 @@ get_identity_uid_for_from (EShell *shell,
/* always use organizer's email when user is an organizer */
if (itip_organizer_is_user (registry, comp, cal_client)) {
ECalComponentOrganizer *organizer;
+ const gchar *organizer_email;
organizer = e_cal_component_get_organizer (comp);
- if (organizer && e_cal_component_organizer_get_value (organizer)) {
- source = find_enabled_identity (
- registry,
- itip_strip_mailto (e_cal_component_organizer_get_value (organizer)));
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+ if (organizer_email) {
+ source = find_enabled_identity (registry, organizer_email);
if (source) {
if (identity_name)
*identity_name = g_strdup (e_cal_component_organizer_get_cn
(organizer));
if (identity_address)
- *identity_address = g_strdup (itip_strip_mailto
(e_cal_component_organizer_get_value (organizer)));
+ *identity_address = g_strdup (organizer_email);
}
}
@@ -2754,6 +2805,7 @@ reply_to_calendar_comp (ESourceRegistry *registry,
ECalComponentDateTime *dtstart;
ICalTimezone *start_zone = NULL;
time_t start;
+ const gchar *organizer_email;
text_list = e_cal_component_get_descriptions (comp);
@@ -2771,8 +2823,9 @@ reply_to_calendar_comp (ESourceRegistry *registry,
e_cal_component_text_free (text);
organizer = e_cal_component_get_organizer (comp);
- if (organizer && e_cal_component_organizer_get_value (organizer))
- orig_from = g_strdup (itip_strip_mailto (e_cal_component_organizer_get_value
(organizer)));
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+ if (organizer_email)
+ orig_from = g_strdup (organizer_email);
e_cal_component_organizer_free (organizer);
location = e_cal_component_get_location (comp);
@@ -2953,15 +3006,18 @@ itip_component_has_recipients (ECalComponent *comp)
GSList *attendees, *link;
ECalComponentAttendee *attendee;
ECalComponentOrganizer *organizer;
+ const gchar *organizer_email;
gboolean res = FALSE;
g_return_val_if_fail (comp != NULL, FALSE);
organizer = e_cal_component_get_organizer (comp);
+ organizer_email = cal_comp_util_get_organizer_email (organizer);
+
attendees = e_cal_component_get_attendees (comp);
if (!attendees) {
- if (organizer && e_cal_component_organizer_get_value (organizer) &&
+ if (organizer_email &&
e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_JOURNAL) {
/* memos store recipients in an extra property */
ICalComponent *icomp;
@@ -2979,7 +3035,7 @@ itip_component_has_recipients (ECalComponent *comp)
if (g_str_equal (x_name, "X-EVOLUTION-RECIPIENTS")) {
const gchar *str_recipients = i_cal_property_get_x (prop);
- res = str_recipients && g_ascii_strcasecmp
(e_cal_component_organizer_get_value (organizer), str_recipients) != 0;
+ res = str_recipients && !itip_email_addresses_equal (organizer_email,
str_recipients);
g_object_unref (prop);
break;
}
@@ -2998,11 +3054,12 @@ itip_component_has_recipients (ECalComponent *comp)
}
for (link = attendees; link && !res; link = g_slist_next (link)) {
+ const gchar *attendee_email;
+
attendee = link->data;
+ attendee_email = cal_comp_util_get_attendee_email (attendee);
- res = organizer && e_cal_component_organizer_get_value (organizer) &&
- attendee && e_cal_component_attendee_get_value (attendee) &&
- g_ascii_strcasecmp (e_cal_component_organizer_get_value (organizer),
e_cal_component_attendee_get_value (attendee)) != 0;
+ res = !itip_email_addresses_equal (organizer_email, attendee_email);
}
g_slist_free_full (attendees, e_cal_component_attendee_free);
@@ -3061,7 +3118,7 @@ itip_utils_find_attendee_property (ICalComponent *icomp,
text = g_strdup (itip_strip_mailto (attendee));
text = g_strstrip (text);
- if (text && !g_ascii_strcasecmp (address, text)) {
+ if (text && itip_email_addresses_equal (address, text)) {
g_free (text);
g_free (attendee);
break;
@@ -3155,9 +3212,9 @@ itip_utils_remove_all_but_attendee (ICalComponent *icomp,
for (prop = i_cal_component_get_first_property (icomp, I_CAL_ATTENDEE_PROPERTY);
prop;
prop = i_cal_component_get_next_property (icomp, I_CAL_ATTENDEE_PROPERTY)) {
- const gchar *address = i_cal_property_get_attendee (prop);
+ const gchar *address = cal_comp_util_get_property_email (prop);
- if (found || g_ascii_strcasecmp (itip_strip_mailto (address), attendee) != 0) {
+ if (found || !itip_email_addresses_equal (address, attendee)) {
remove = g_slist_prepend (remove, prop);
} else {
found = TRUE;
diff --git a/src/calendar/gui/itip-utils.h b/src/calendar/gui/itip-utils.h
index d2aba970f3..87bf7854e9 100644
--- a/src/calendar/gui/itip-utils.h
+++ b/src/calendar/gui/itip-utils.h
@@ -46,7 +46,8 @@ struct CalMimeAttach {
};
void itip_cal_mime_attach_free (gpointer ptr); /* struct CalMimeAttach * */
-
+gboolean itip_email_addresses_equal (const gchar *email1,
+ const gchar *email2);
gboolean itip_get_default_name_and_address
(ESourceRegistry *registry,
gchar **name,
diff --git a/src/calendar/gui/print.c b/src/calendar/gui/print.c
index 43ef9e2fbe..3f574a5ce1 100644
--- a/src/calendar/gui/print.c
+++ b/src/calendar/gui/print.c
@@ -1312,7 +1312,7 @@ print_attendees (GtkPrintContext *context,
if (!attendee)
continue;
- value = e_cal_component_attendee_get_value (attendee);
+ value = cal_comp_util_get_attendee_email (attendee);
if (value && *value) {
GString *text;
const gchar *tmp;
diff --git a/src/calendar/importers/icalendar-importer.c b/src/calendar/importers/icalendar-importer.c
index 11f6a465f6..54a2083907 100644
--- a/src/calendar/importers/icalendar-importer.c
+++ b/src/calendar/importers/icalendar-importer.c
@@ -1241,6 +1241,73 @@ strip_mailto (const gchar *str)
return str + 7;
}
+static const gchar *
+get_property_value_email (const gchar *value,
+ ECalComponentParameterBag *params)
+{
+ const gchar *address = NULL;
+
+ if (params) {
+ guint email_index;
+
+ #ifdef HAVE_I_CAL_EMAIL_PARAMETER
+ email_index = e_cal_component_parameter_bag_get_first_by_kind (params, I_CAL_EMAIL_PARAMETER);
+ #else
+ email_index = e_cal_component_parameter_bag_get_first_by_kind (params, (ICalParameterKind)
ICAL_EMAIL_PARAMETER);
+ #endif
+
+ if (email_index < e_cal_component_parameter_bag_get_count (params)) {
+ ICalParameter *param;
+
+ param = e_cal_component_parameter_bag_get (params, email_index);
+
+ if (param) {
+ #ifdef HAVE_I_CAL_EMAIL_PARAMETER
+ address = i_cal_parameter_get_email (param);
+ #else
+ address = icalparameter_get_email (i_cal_object_get_native (I_CAL_OBJECT
(param)));
+ #endif
+
+ if (address && !*address)
+ address = NULL;
+ }
+ }
+ }
+
+ if (!address)
+ address = value;
+
+ if (address)
+ address = strip_mailto (address);
+
+ if (address && !*address)
+ address = NULL;
+
+ return address;
+}
+
+static const gchar *
+get_organizer_email (ECalComponentOrganizer *organizer)
+{
+ if (!organizer)
+ return NULL;
+
+ return get_property_value_email (
+ e_cal_component_organizer_get_value (organizer),
+ e_cal_component_organizer_get_parameter_bag (organizer));
+}
+
+static const gchar *
+get_attendee_email (ECalComponentAttendee *attendee)
+{
+ if (!attendee)
+ return NULL;
+
+ return get_property_value_email (
+ e_cal_component_attendee_get_value (attendee),
+ e_cal_component_attendee_get_parameter_bag (attendee));
+}
+
static void
add_url_section (EWebViewPreview *preview,
const gchar *section,
@@ -1421,22 +1488,23 @@ preview_comp (EWebViewPreview *preview,
if (e_cal_component_has_organizer (comp)) {
ECalComponentOrganizer *organizer;
+ const gchar *organizer_email;
organizer = e_cal_component_get_organizer (comp);
+ organizer_email = get_organizer_email (organizer);
- if (organizer && e_cal_component_organizer_get_value (organizer)) {
- const gchar *value, *cn;
+ if (organizer_email) {
+ const gchar *cn;
- value = e_cal_component_organizer_get_value (organizer);
cn = e_cal_component_organizer_get_cn (organizer);
if (cn && *cn) {
- tmp = g_strconcat (cn, " <", strip_mailto (value), ">", NULL);
+ tmp = g_strconcat (cn, " <", organizer_email, ">", NULL);
/* Translators: Appointment's organizer */
e_web_view_preview_add_section (preview, C_("iCalImp", "Organizer"), tmp);
g_free (tmp);
} else {
- e_web_view_preview_add_section (preview, C_("iCalImp", "Organizer"),
strip_mailto (value));
+ e_web_view_preview_add_section (preview, C_("iCalImp", "Organizer"),
organizer_email);
}
}
@@ -1456,7 +1524,7 @@ preview_comp (EWebViewPreview *preview,
if (!attnd)
continue;
- value = e_cal_component_attendee_get_value (attnd);
+ value = get_attendee_email (attnd);
if (!value || !*value)
continue;
diff --git a/src/modules/calendar/e-cal-shell-content.c b/src/modules/calendar/e-cal-shell-content.c
index d9ab9fa2ed..4bac56e6f4 100644
--- a/src/modules/calendar/e-cal-shell-content.c
+++ b/src/modules/calendar/e-cal-shell-content.c
@@ -903,9 +903,9 @@ cal_shell_content_get_attendee_prop (ICalComponent *icomp,
g_object_unref (prop), prop = i_cal_component_get_next_property (icomp,
I_CAL_ATTENDEE_PROPERTY)) {
const gchar *attendee;
- attendee = itip_strip_mailto (i_cal_property_get_attendee (prop));
+ attendee = cal_comp_util_get_property_email (prop);
- if (attendee && g_ascii_strcasecmp (attendee, address) == 0)
+ if (itip_email_addresses_equal (attendee, address))
return prop;
}
diff --git a/src/modules/calendar/e-cal-shell-view-actions.c b/src/modules/calendar/e-cal-shell-view-actions.c
index 0c282cc105..2838cf1a5a 100644
--- a/src/modules/calendar/e-cal-shell-view-actions.c
+++ b/src/modules/calendar/e-cal-shell-view-actions.c
@@ -669,10 +669,9 @@ action_event_delegate_cb (GtkAction *action,
g_object_unref (prop), prop = i_cal_component_get_next_property (clone,
I_CAL_ATTENDEE_PROPERTY)) {
const gchar *candidate;
- candidate = i_cal_property_get_attendee (prop);
- candidate = itip_strip_mailto (candidate);
+ candidate = cal_comp_util_get_property_email (prop);
- if (candidate && g_ascii_strcasecmp (candidate, attendee) == 0) {
+ if (itip_email_addresses_equal (candidate, attendee)) {
ICalParameter *param;
param = i_cal_parameter_new_role (I_CAL_ROLE_NONPARTICIPANT);
diff --git a/src/modules/composer-to-meeting/e-meeting-to-composer.c
b/src/modules/composer-to-meeting/e-meeting-to-composer.c
index 63437521d7..955e3e8022 100644
--- a/src/modules/composer-to-meeting/e-meeting-to-composer.c
+++ b/src/modules/composer-to-meeting/e-meeting-to-composer.c
@@ -24,6 +24,7 @@
#include "e-util/e-util.h"
#include "composer/e-msg-composer.h"
#include "composer/e-composer-from-header.h"
+#include "calendar/gui/comp-util.h"
#include "calendar/gui/e-comp-editor.h"
#include "calendar/gui/e-comp-editor-page-attachments.h"
#include "calendar/gui/itip-utils.h"
@@ -190,7 +191,7 @@ meeting_to_composer_composer_created_cb (GObject *source_object,
const gchar *organizer;
from_header = e_composer_header_table_get_header (header_table, E_COMPOSER_HEADER_FROM);
- organizer = itip_strip_mailto (i_cal_property_get_organizer (prop));
+ organizer = cal_comp_util_get_property_email (prop);
if (organizer && *organizer && from_header) {
GtkComboBox *identities_combo;
@@ -243,7 +244,7 @@ meeting_to_composer_composer_created_cb (GObject *source_object,
const gchar *name = NULL, *address;
EDestination *dest;
- address = itip_strip_mailto (i_cal_property_get_attendee (prop));
+ address = cal_comp_util_get_property_email (prop);
if (!address || !*address)
continue;
diff --git a/src/modules/itip-formatter/itip-view.c b/src/modules/itip-formatter/itip-view.c
index 8781f549c0..9eff415052 100644
--- a/src/modules/itip-formatter/itip-view.c
+++ b/src/modules/itip-formatter/itip-view.c
@@ -2608,7 +2608,7 @@ itip_view_format_attendee_plaintext (ICalProperty *prop)
if (!prop)
return NULL;
- email = i_cal_property_get_attendee (prop);
+ email = cal_comp_util_get_property_email (prop);
cnparam = i_cal_property_get_first_parameter (prop, I_CAL_CN_PARAMETER);
if (cnparam) {
cn = i_cal_parameter_get_cn (cnparam);
@@ -2616,8 +2616,6 @@ itip_view_format_attendee_plaintext (ICalProperty *prop)
cn = NULL;
}
- email = itip_strip_mailto (email);
-
if ((email && *email) || (cn && *cn)) {
str = g_string_new ("");
@@ -3857,9 +3855,8 @@ same_attendee_status (ItipView *view,
if (!sattendee)
continue;
- if (e_cal_component_attendee_get_value (rattendee) &&
- e_cal_component_attendee_get_value (sattendee) &&
- g_ascii_strcasecmp (e_cal_component_attendee_get_value (rattendee),
e_cal_component_attendee_get_value (sattendee)) == 0) {
+ if (itip_email_addresses_equal (cal_comp_util_get_attendee_email (rattendee),
+ cal_comp_util_get_attendee_email (sattendee))) {
same = e_cal_component_attendee_get_partstat (rattendee) ==
e_cal_component_attendee_get_partstat (sattendee);
break;
}
@@ -5032,18 +5029,18 @@ finish_message_delete_with_rsvp (ItipView *view,
g_object_unref (prop), prop = i_cal_component_get_next_property (icomp,
I_CAL_ATTENDEE_PROPERTY)) {
gchar *text;
- attendee = i_cal_property_get_attendee (prop);
+ attendee = cal_comp_util_get_property_email (prop);
if (!attendee)
continue;
- text = g_strdup (itip_strip_mailto (attendee));
+ text = g_strdup (attendee);
text = g_strstrip (text);
/* We do this to ensure there is at most one
* attendee in the response */
- if (found || g_ascii_strcasecmp (view->priv->to_address, text))
+ if (found || !itip_email_addresses_equal (view->priv->to_address, text))
list = g_slist_prepend (list, g_object_ref (prop));
- else if (!g_ascii_strcasecmp (view->priv->to_address, text))
+ else if (itip_email_addresses_equal (view->priv->to_address, text))
found = TRUE;
g_free (text);
}
@@ -5629,22 +5626,23 @@ update_attendee_status_icomp (ItipView *view,
ECalComponentAttendee *a = attendees->data;
ICalProperty *prop, *del_prop = NULL, *delto = NULL;
EShell *shell = e_shell_get_default ();
+ const gchar *attendee_email = cal_comp_util_get_attendee_email (a);
- prop = itip_utils_find_attendee_property (icomp, itip_strip_mailto
(e_cal_component_attendee_get_value (a)));
+ prop = itip_utils_find_attendee_property (icomp, attendee_email);
if ((e_cal_component_attendee_get_partstat (a) == I_CAL_PARTSTAT_DELEGATED) &&
(del_prop = itip_utils_find_attendee_property (org_icomp, itip_strip_mailto
(e_cal_component_attendee_get_delegatedto (a)))) &&
!(delto = itip_utils_find_attendee_property (icomp, itip_strip_mailto
(e_cal_component_attendee_get_delegatedto (a))))) {
gint response;
- delegate = i_cal_property_get_attendee (del_prop);
+ delegate = cal_comp_util_get_property_email (del_prop);
response = e_alert_run_dialog_for_args (
e_shell_get_active_window (shell),
"org.gnome.itip-formatter:add-delegate",
- itip_strip_mailto (e_cal_component_attendee_get_value (a)),
+ attendee_email,
itip_strip_mailto (delegate), NULL);
if (response == GTK_RESPONSE_YES) {
i_cal_component_take_property (icomp, i_cal_property_clone
(del_prop));
} else if (response == GTK_RESPONSE_NO) {
- remove_delegate (view, delegate, itip_strip_mailto
(e_cal_component_attendee_get_value (a)), comp);
+ remove_delegate (view, delegate, attendee_email, comp);
g_clear_object (&del_prop);
g_clear_object (&delto);
goto cleanup;
@@ -5669,15 +5667,15 @@ update_attendee_status_icomp (ItipView *view,
e_shell_get_active_window (shell),
"org.gnome.itip-formatter:add-delegate",
itip_strip_mailto (delfrom),
- itip_strip_mailto (e_cal_component_attendee_get_value (a)),
NULL);
+ attendee_email, NULL);
if (response == GTK_RESPONSE_YES) {
/* Already declared in this function */
- ICalProperty *prop = itip_utils_find_attendee_property
(icomp, itip_strip_mailto (e_cal_component_attendee_get_value (a)));
+ ICalProperty *prop = itip_utils_find_attendee_property
(icomp, attendee_email);
i_cal_component_take_property (icomp, i_cal_property_clone
(prop));
} else if (response == GTK_RESPONSE_NO) {
remove_delegate (
view,
- itip_strip_mailto (e_cal_component_attendee_get_value
(a)),
+ attendee_email,
itip_strip_mailto (delfrom),
comp);
goto cleanup;
@@ -5693,7 +5691,7 @@ update_attendee_status_icomp (ItipView *view,
if (response == GTK_RESPONSE_YES) {
itip_utils_prepare_attendee_response (
view->priv->registry, icomp,
- itip_strip_mailto (e_cal_component_attendee_get_value (a)),
+ attendee_email,
e_cal_component_attendee_get_partstat (a));
} else {
goto cleanup;
@@ -5710,17 +5708,17 @@ update_attendee_status_icomp (ItipView *view,
/* *prop already declared in this function */
ICalProperty *subprop, *new_prop;
- subprop = itip_utils_find_attendee_property (icomp, itip_strip_mailto
(e_cal_component_attendee_get_value (a)));
+ subprop = itip_utils_find_attendee_property (icomp, attendee_email);
i_cal_component_remove_property (icomp, subprop);
g_clear_object (&subprop);
- new_prop = itip_utils_find_attendee_property (org_icomp,
itip_strip_mailto (e_cal_component_attendee_get_value (a)));
+ new_prop = itip_utils_find_attendee_property (org_icomp,
attendee_email);
i_cal_component_take_property (icomp, i_cal_property_clone
(new_prop));
g_clear_object (&new_prop);
} else {
itip_utils_prepare_attendee_response (
view->priv->registry, icomp,
- itip_strip_mailto (e_cal_component_attendee_get_value (a)),
+ attendee_email,
e_cal_component_attendee_get_partstat (a));
}
@@ -6696,7 +6694,7 @@ itip_view_init_view (ItipView *view)
break;
org = e_cal_component_organizer_get_cn (organizer) ?
e_cal_component_organizer_get_cn (organizer) :
- itip_strip_mailto (e_cal_component_organizer_get_value (organizer));
+ cal_comp_util_get_organizer_email (organizer);
itip_view_set_organizer (view, org);
if (e_cal_component_organizer_get_sentby (organizer)) {
@@ -6716,7 +6714,7 @@ itip_view_init_view (ItipView *view)
if (camel_address_decode (CAMEL_ADDRESS
(addr), sender) == 1 &&
camel_internet_address_get (addr, 0,
&name, &email) &&
name && *name && email && *email &&
- g_ascii_strcasecmp (sentby, email) == 0) {
+ itip_email_addresses_equal (sentby,
email)) {
tmp =
camel_internet_address_format_address (name, sentby);
sentby = tmp;
}
@@ -6732,11 +6730,9 @@ itip_view_init_view (ItipView *view)
}
if (view->priv->my_address) {
- if (!(e_cal_component_organizer_get_value (organizer) &&
- !g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_organizer_get_value (organizer)), view->priv->my_address)) &&
- !(e_cal_component_organizer_get_sentby (organizer) &&
- !g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_organizer_get_sentby (organizer)), view->priv->my_address)) &&
- (view->priv->to_address && g_ascii_strcasecmp
(view->priv->to_address, view->priv->my_address)))
+ if (!itip_email_addresses_equal (cal_comp_util_get_organizer_email
(organizer), view->priv->my_address) &&
+ !itip_email_addresses_equal (e_cal_component_organizer_get_sentby
(organizer), view->priv->my_address) &&
+ (view->priv->to_address && !itip_email_addresses_equal
(view->priv->to_address, view->priv->my_address)))
itip_view_set_proxy (view, view->priv->to_name ?
view->priv->to_name : view->priv->to_address);
}
@@ -6755,17 +6751,15 @@ itip_view_init_view (ItipView *view)
attendee = list->data;
itip_view_set_attendee (view, e_cal_component_attendee_get_cn
(attendee) ?
- e_cal_component_attendee_get_cn (attendee) :
itip_strip_mailto (e_cal_component_attendee_get_value (attendee)));
+ e_cal_component_attendee_get_cn (attendee) :
cal_comp_util_get_attendee_email (attendee));
if (e_cal_component_attendee_get_sentby (attendee))
itip_view_set_attendee_sentby (view, itip_strip_mailto
(e_cal_component_attendee_get_sentby (attendee)));
if (view->priv->my_address) {
- if (!(e_cal_component_attendee_get_value (attendee) &&
- !g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_attendee_get_value (attendee)), view->priv->my_address)) &&
- !(e_cal_component_attendee_get_sentby (attendee) &&
- !g_ascii_strcasecmp (itip_strip_mailto
(e_cal_component_attendee_get_sentby (attendee)), view->priv->my_address)) &&
- (view->priv->from_address && g_ascii_strcasecmp
(view->priv->from_address, view->priv->my_address)))
+ if (!itip_email_addresses_equal
(cal_comp_util_get_attendee_email (attendee), view->priv->my_address) &&
+ !itip_email_addresses_equal
(e_cal_component_attendee_get_sentby (attendee), view->priv->my_address) &&
+ (view->priv->from_address && !itip_email_addresses_equal
(view->priv->from_address, view->priv->my_address)))
itip_view_set_proxy (view, view->priv->from_name ?
view->priv->from_name : view->priv->from_address);
}
diff --git a/src/plugins/save-calendar/csv-format.c b/src/plugins/save-calendar/csv-format.c
index 4272f89a63..fec85782dc 100644
--- a/src/plugins/save-calendar/csv-format.c
+++ b/src/plugins/save-calendar/csv-format.c
@@ -90,7 +90,7 @@ add_list_to_csv (GString *line,
needquotes = TRUE;
switch (type) {
case ECALCOMPONENTATTENDEE:
- str = itip_strip_mailto (e_cal_component_attendee_get_value
(((ECalComponentAttendee *) list->data)));
+ str = cal_comp_util_get_attendee_email (((ECalComponentAttendee *)
list->data));
break;
case ECALCOMPONENTTEXT:
str = e_cal_component_text_get_value (((ECalComponentText *) list->data));
diff --git a/src/plugins/save-calendar/format-handler.h b/src/plugins/save-calendar/format-handler.h
index 61665e41fb..e3457a47a1 100644
--- a/src/plugins/save-calendar/format-handler.h
+++ b/src/plugins/save-calendar/format-handler.h
@@ -24,6 +24,7 @@
#include <e-util/e-util.h>
#include <calendar/gui/itip-utils.h>
+#include <calendar/gui/comp-util.h>
typedef struct _FormatHandler FormatHandler;
diff --git a/src/plugins/save-calendar/rdf-format.c b/src/plugins/save-calendar/rdf-format.c
index 2c7079e12a..a7c35cb771 100644
--- a/src/plugins/save-calendar/rdf-format.c
+++ b/src/plugins/save-calendar/rdf-format.c
@@ -95,7 +95,7 @@ add_list_to_rdf (xmlNodePtr node,
switch (type) {
case ECALCOMPONENTATTENDEE:
- str = itip_strip_mailto (e_cal_component_attendee_get_value
((ECalComponentAttendee *) list->data));
+ str = cal_comp_util_get_attendee_email ((ECalComponentAttendee *) list->data);
break;
case ECALCOMPONENTTEXT:
str = e_cal_component_text_get_value ((ECalComponentText *) list->data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]