[evolution-ews/gnome-3-26] Bug 793037 - Some appointments displayed as meetings



commit ee19556f276c150fb25a4576cd54abd6ca10ae63
Author: Milan Crha <mcrha redhat com>
Date:   Fri Feb 2 10:57:28 2018 +0100

    Bug 793037 - Some appointments displayed as meetings

 src/calendar/e-cal-backend-ews.c |   85 ++++++++++++++++++++------------------
 src/server/e-ews-item.c          |   14 ++++++
 src/server/e-ews-item.h          |    1 +
 3 files changed, 60 insertions(+), 40 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 7db264f..d71cf97 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -85,6 +85,7 @@ struct _ECalBackendEwsPrivate {
        " calendar:UID" \
        " calendar:Resources" \
        " calendar:ModifiedOccurrences" \
+       " calendar:IsMeeting" \
        " calendar:MyResponseType" \
        " calendar:RequiredAttendees" \
        " calendar:OptionalAttendees"
@@ -657,59 +658,63 @@ ecb_ews_item_to_component_sync (ECalBackendEws *cbews,
                const EwsId *item_id;
                const GSList *l = NULL;
                const gchar *uid = e_ews_item_get_uid (item);
-               gchar *user_email;
 
                item_id = e_ews_item_get_id (item);
-               user_email = camel_ews_settings_dup_email (ews_settings);
 
-               /* Attendees */
-               for (l = e_ews_item_get_attendees (item); l != NULL; l = g_slist_next (l)) {
-                       icalparameter *param, *cu_type;
-                       gchar *mailtoname;
-                       const gchar *email = NULL;
-                       EwsAttendee *attendee = (EwsAttendee *) l->data;
+               if (e_ews_item_get_is_meeting (item)) {
+                       gchar *user_email;
 
-                       if (!attendee->mailbox)
-                               continue;
+                       user_email = camel_ews_settings_dup_email (ews_settings);
 
-                       if (g_strcmp0 (attendee->mailbox->routing_type, "EX") == 0)
-                               email = e_ews_item_util_strip_ex_address (attendee->mailbox->email);
+                       /* Attendees */
+                       for (l = e_ews_item_get_attendees (item); l != NULL; l = g_slist_next (l)) {
+                               icalparameter *param, *cu_type;
+                               gchar *mailtoname;
+                               const gchar *email = NULL;
+                               EwsAttendee *attendee = (EwsAttendee *) l->data;
 
-                       mailtoname = g_strdup_printf ("mailto:%s";, email ? email : attendee->mailbox->email);
-                       icalprop = icalproperty_new_attendee (mailtoname);
-                       g_free (mailtoname);
+                               if (!attendee->mailbox)
+                                       continue;
 
-                       param = icalparameter_new_cn (attendee->mailbox->name);
-                       icalproperty_add_parameter (icalprop, param);
+                               if (g_strcmp0 (attendee->mailbox->routing_type, "EX") == 0)
+                                       email = e_ews_item_util_strip_ex_address (attendee->mailbox->email);
 
-                       if (g_ascii_strcasecmp (attendee->attendeetype, "Required") == 0) {
-                               param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
-                               cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
-                       }
-                       else if (g_ascii_strcasecmp (attendee->attendeetype, "Resource") == 0) {
-                               param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
-                               cu_type = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
-                       }
-                       else {
-                               param = icalparameter_new_role ( ICAL_ROLE_OPTPARTICIPANT);
-                               cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
-                       }
-                       icalproperty_add_parameter (icalprop, cu_type);
-                       icalproperty_add_parameter (icalprop, param);
+                               mailtoname = g_strdup_printf ("mailto:%s";, email ? email : 
attendee->mailbox->email);
+                               icalprop = icalproperty_new_attendee (mailtoname);
+                               g_free (mailtoname);
 
-                       if (user_email && (email || attendee->mailbox->email) && 
e_ews_item_get_my_response_type (item) &&
-                           g_ascii_strcasecmp (email ? email : attendee->mailbox->email, user_email) == 0) {
-                               param = ecb_ews_responsetype_to_partstat (e_ews_item_get_my_response_type 
(item));
-                       } else {
-                               param = ecb_ews_responsetype_to_partstat (attendee->responsetype);
+                               param = icalparameter_new_cn (attendee->mailbox->name);
+                               icalproperty_add_parameter (icalprop, param);
+
+                               if (g_ascii_strcasecmp (attendee->attendeetype, "Required") == 0) {
+                                       param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT);
+                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+                               }
+                               else if (g_ascii_strcasecmp (attendee->attendeetype, "Resource") == 0) {
+                                       param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
+                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_RESOURCE);
+                               }
+                               else {
+                                       param = icalparameter_new_role ( ICAL_ROLE_OPTPARTICIPANT);
+                                       cu_type = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
+                               }
+                               icalproperty_add_parameter (icalprop, cu_type);
+                               icalproperty_add_parameter (icalprop, param);
+
+                               if (user_email && (email || attendee->mailbox->email) && 
e_ews_item_get_my_response_type (item) &&
+                                   g_ascii_strcasecmp (email ? email : attendee->mailbox->email, user_email) 
== 0) {
+                                       param = ecb_ews_responsetype_to_partstat 
(e_ews_item_get_my_response_type (item));
+                               } else {
+                                       param = ecb_ews_responsetype_to_partstat (attendee->responsetype);
+                               }
+                               icalproperty_add_parameter (icalprop, param);
+
+                               icalcomponent_add_property (icalcomp, icalprop);
                        }
-                       icalproperty_add_parameter (icalprop, param);
 
-                       icalcomponent_add_property (icalcomp, icalprop);
+                       g_free (user_email);
                }
 
-               g_free (user_email);
-
                /* Free/Busy */
                freebusy = icalcomponent_get_first_property (icalcomp, ICAL_TRANSP_PROPERTY);
                if (!freebusy && (e_ews_item_get_item_type (item) != E_EWS_ITEM_TYPE_TASK)) {
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index 3f9ae98..dc346cc 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -134,6 +134,7 @@ struct _EEwsItemPrivate {
        EwsMailbox *from;
        EwsMailbox *sender;
 
+       gboolean is_meeting;
        GSList *modified_occurrences;
        GSList *attachments_ids;
        gchar *my_response_type;
@@ -300,6 +301,7 @@ e_ews_item_init (EEwsItem *item)
        item->priv = G_TYPE_INSTANCE_GET_PRIVATE (item, E_TYPE_EWS_ITEM, EEwsItemPrivate);
 
        item->priv->item_type = E_EWS_ITEM_TYPE_UNKNOWN;
+       item->priv->is_meeting = FALSE;
 
        item->priv->mapi_extended_tags = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
        item->priv->mapi_extended_sets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, 
(GDestroyNotify) g_hash_table_destroy);
@@ -1140,6 +1142,10 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item,
                        parse_extended_property (priv, subparam);
                } else if (!g_ascii_strcasecmp (name, "ModifiedOccurrences")) {
                        process_modified_occurrences (priv, subparam);
+               } else if (!g_ascii_strcasecmp (name, "IsMeeting")) {
+                       value = e_soap_parameter_get_string_value (subparam);
+                       priv->is_meeting = (!g_ascii_strcasecmp (value, "true"));
+                       g_free (value);
                } else if (!g_ascii_strcasecmp (name, "MyResponseType")) {
                        g_free (priv->my_response_type);
                        priv->my_response_type = e_soap_parameter_get_string_value (subparam);
@@ -1389,6 +1395,14 @@ e_ews_item_is_read (EEwsItem *item,
 }
 
 gboolean
+e_ews_item_get_is_meeting (EEwsItem *item)
+{
+       g_return_val_if_fail (E_IS_EWS_ITEM (item), FALSE);
+
+       return item->priv->is_meeting;
+}
+
+gboolean
 e_ews_item_is_forwarded (EEwsItem *item,
                          gboolean *forwarded)
 {
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 88a540e..f5ee3df 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -215,6 +215,7 @@ EwsMailbox *
                                                (ESoapParameter *param);
 void           e_ews_mailbox_free              (EwsMailbox *mailbox);
 
+gboolean       e_ews_item_get_is_meeting       (EEwsItem *item);
 const GSList * e_ews_item_get_modified_occurrences
                                                (EEwsItem *item);
 gchar *                e_ews_embed_attachment_id_in_uri (const gchar *olduri, const gchar *attach_id);


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