[evolution-ews] Bug 743654 - Show user's meeting response in the Calendar view



commit 9017cf354c24b45b7e3fc71c02508ac0f121a282
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 31 17:43:29 2016 +0200

    Bug 743654 - Show user's meeting response in the Calendar view

 src/calendar/e-cal-backend-ews.c |   45 +++++++++++++++++++++++++++----------
 src/server/e-ews-item.c          |   15 ++++++++++++
 src/server/e-ews-item.h          |    1 +
 3 files changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index db33ad2..c46dfcd 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -104,6 +104,7 @@ struct _ECalBackendEwsPrivate {
        " calendar:UID" \
        " calendar:Resources" \
        " calendar:ModifiedOccurrences" \
+       " calendar:MyResponseType" \
        " calendar:RequiredAttendees" \
        " calendar:OptionalAttendees"
 
@@ -3012,6 +3013,32 @@ get_timezone (ETimezoneCache *timezone_cache,
        return zone;
 }
 
+static icalparameter *
+cal_backend_ews_responsetype_to_partstat (const gchar *responsetype)
+{
+       icalparameter *param = NULL;
+
+       g_return_val_if_fail (responsetype != NULL, NULL);
+
+       if (g_ascii_strcasecmp (responsetype, "Organizer") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+       else if (g_ascii_strcasecmp (responsetype, "Tentative") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
+       else if (g_ascii_strcasecmp (responsetype, "Accept") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
+       else if (g_ascii_strcasecmp (responsetype, "Decline") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
+       else if (g_ascii_strcasecmp (responsetype, "NoResponseReceived") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
+       else if (g_ascii_strcasecmp (responsetype, "Unknown") == 0)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_NONE);
+
+       if (!param)
+               param = icalparameter_new_partstat (ICAL_PARTSTAT_NONE);
+
+       return param;
+}
+
 static void
 add_item_to_cache (ECalBackendEws *cbews,
                    EEwsItem *item)
@@ -3339,18 +3366,12 @@ add_item_to_cache (ECalBackendEws *cbews,
                        icalproperty_add_parameter (icalprop, cu_type);
                        icalproperty_add_parameter (icalprop, param);
 
-                       if (g_ascii_strcasecmp (attendee->responsetype, "Organizer") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
-                       else if (g_ascii_strcasecmp (attendee->responsetype, "Tentative") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_TENTATIVE);
-                       else if (g_ascii_strcasecmp (attendee->responsetype, "Accept") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_ACCEPTED);
-                       else if (g_ascii_strcasecmp (attendee->responsetype, "Decline") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_DECLINED);
-                       else if (g_ascii_strcasecmp (attendee->responsetype, "NoResponseReceived") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_NEEDSACTION);
-                       else if (g_ascii_strcasecmp (attendee->responsetype, "Unknown") == 0)
-                               param = icalparameter_new_partstat (ICAL_PARTSTAT_NONE);
+                       if (cbews->priv->user_email && (email || attendee->mailbox->email) && 
e_ews_item_get_my_response_type (item) &&
+                           g_ascii_strcasecmp (email ? email : attendee->mailbox->email, 
cbews->priv->user_email) == 0) {
+                               param = cal_backend_ews_responsetype_to_partstat 
(e_ews_item_get_my_response_type (item));
+                       } else {
+                               param = cal_backend_ews_responsetype_to_partstat (attendee->responsetype);
+                       }
                        icalproperty_add_parameter (icalprop, param);
 
                        icalcomponent_add_property (icalcomp, icalprop);
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index f09553f..9ad25ce 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -135,6 +135,7 @@ struct _EEwsItemPrivate {
 
        GSList *modified_occurrences;
        GSList *attachments_ids;
+       gchar *my_response_type;
        GSList *attendees;
 
        EwsId *calendar_item_accept_id;
@@ -240,6 +241,9 @@ e_ews_item_dispose (GObject *object)
        g_slist_free_full (priv->attachments_ids, g_free);
        priv->attachments_ids = NULL;
 
+       g_free (priv->my_response_type);
+       priv->my_response_type = NULL;
+
        g_slist_free_full (priv->attendees, (GDestroyNotify) ews_item_free_attendee);
        priv->attendees = NULL;
 
@@ -1112,6 +1116,9 @@ 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, "MyResponseType")) {
+                       g_free (priv->my_response_type);
+                       priv->my_response_type = e_soap_parameter_get_string_value (subparam);
                } else if (!g_ascii_strcasecmp (name, "RequiredAttendees")) {
                        process_attendees (priv, subparam, "Required");
                } else if (!g_ascii_strcasecmp (name, "OptionalAttendees")) {
@@ -1813,6 +1820,14 @@ e_ews_item_dump_mime_content (EEwsItem *item,
        return info;
 }
 
+const gchar *
+e_ews_item_get_my_response_type (EEwsItem *item)
+{
+       g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
+
+       return item->priv->my_response_type;
+}
+
 const GSList *
 e_ews_item_get_attendees (EEwsItem *item)
 {
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 725ffc6..304d542 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -259,6 +259,7 @@ e_ews_item_ical_dump (EEwsItem *item);
 EEwsAttachmentInfo *
 e_ews_item_dump_mime_content (EEwsItem *item, const gchar *cache);
 
+const gchar *  e_ews_item_get_my_response_type (EEwsItem *item);
 const GSList * e_ews_item_get_attendees        (EEwsItem *item);
 
 const EwsId *  e_ews_item_get_calendar_item_accept_id


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