[evolution-ews] evo-I#1097 - Provide HTML invitation description, when available
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] evo-I#1097 - Provide HTML invitation description, when available
- Date: Thu, 17 Sep 2020 10:11:46 +0000 (UTC)
commit 5415b6c65ae634acadd15e1b0f6a97620c7d327a
Author: Milan Crha <mcrha redhat com>
Date: Thu Sep 17 12:10:24 2020 +0200
evo-I#1097 - Provide HTML invitation description, when available
Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1097
src/EWS/camel/camel-ews-folder.c | 53 +++++++++++++++++++++++++++++++++------
src/EWS/common/e-ews-connection.h | 7 ------
src/EWS/common/e-ews-item.c | 24 ++++++++++++++++++
src/EWS/common/e-ews-item.h | 8 ++++++
4 files changed, 78 insertions(+), 14 deletions(-)
---
diff --git a/src/EWS/camel/camel-ews-folder.c b/src/EWS/camel/camel-ews-folder.c
index 5d6b77fb..1cc646e2 100644
--- a/src/EWS/camel/camel-ews-folder.c
+++ b/src/EWS/camel/camel-ews-folder.c
@@ -340,6 +340,7 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
const EwsId *calendar_item_id,
gboolean is_calendar_UID,
const EwsId *mail_item_id,
+ const gchar *html_body,
GError **error)
{
CamelMimeParser *mimeparser;
@@ -418,6 +419,21 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
i_cal_property_set_x_name (prop, "X-EVOLUTION-ACCEPT-ID");
i_cal_component_take_property (subcomp, prop);
+ if (html_body && *html_body) {
+ prop = i_cal_component_get_first_property (subcomp,
I_CAL_DESCRIPTION_PROPERTY);
+
+ /* The server can return empty HTML (with "<html><body></body></html>" only),
+ thus add it only if there was any DESCRIPTION provided as well. */
+ if (prop) {
+ g_clear_object (&prop);
+
+ prop = i_cal_property_new_x (html_body);
+ i_cal_property_set_x_name (prop, "X-ALT-DESC");
+ i_cal_property_set_parameter_from_string (prop, "FMTTYPE",
"text/html");
+ i_cal_component_take_property (subcomp, prop);
+ }
+ }
+
calstring_new = i_cal_component_as_ical_string (icomp);
if (calstring_new) {
camel_mime_part_set_content (
@@ -832,14 +848,16 @@ camel_ews_folder_get_message (CamelFolder *folder,
e_ews_item_get_item_type (items->data) == E_EWS_ITEM_TYPE_MEETING_CANCELLATION ||
e_ews_item_get_item_type (items->data) == E_EWS_ITEM_TYPE_MEETING_MESSAGE ||
e_ews_item_get_item_type (items->data) == E_EWS_ITEM_TYPE_MEETING_RESPONSE) {
- GSList *items_req = NULL;
+ GSList *items_req = NULL, *html_body_resp = NULL;
+ GSList *html_body_ids;
const EwsId *calendar_item_accept_id = NULL;
+ const gchar *html_body = NULL;
gboolean is_calendar_UID = TRUE;
add_props = e_ews_additional_props_new ();
add_props->field_uri = g_strdup ("meeting:AssociatedCalendarItemId");
- // Get AssociatedCalendarItemId with second get_items call
+ /* Get AssociatedCalendarItemId with second get_items call */
res = e_ews_connection_get_items_sync (
cnc, pri, ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY,
@@ -870,14 +888,35 @@ camel_ews_folder_get_message (CamelFolder *folder,
calendar_item_accept_id = e_ews_item_get_id (items->data);
is_calendar_UID = FALSE;
}
- mime_fname_new = ews_update_mgtrequest_mime_calendar_itemid (mime_content,
calendar_item_accept_id, is_calendar_UID, e_ews_item_get_id (items->data), error);
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("item:Body");
+
+ html_body_ids = g_slist_prepend (NULL, calendar_item_accept_id->id);
+
+ if (e_ews_connection_get_items_sync (
+ cnc, pri, html_body_ids, "IdOnly", add_props,
+ FALSE, NULL, E_EWS_BODY_TYPE_BEST,
+ &html_body_resp,
+ (ESoapProgressFn) camel_operation_progress,
+ (gpointer) cancellable,
+ cancellable, NULL) && html_body_resp && e_ews_item_get_item_type
(html_body_resp->data) != E_EWS_ITEM_TYPE_ERROR) {
+ EEwsItem *item = html_body_resp->data;
+
+ if (e_ews_item_get_body_type (item) == E_EWS_BODY_TYPE_HTML) {
+ html_body = e_ews_item_get_body (item);
+ }
+ }
+
+ e_ews_additional_props_free (add_props);
+ g_slist_free (html_body_ids);
+
+ mime_fname_new = ews_update_mgtrequest_mime_calendar_itemid (mime_content,
calendar_item_accept_id, is_calendar_UID, e_ews_item_get_id (items->data), html_body, error);
if (mime_fname_new)
mime_content = (const gchar *) mime_fname_new;
- if (items_req != NULL) {
- g_object_unref (items_req->data);
- g_slist_free (items_req);
- }
+ g_slist_free_full (html_body_resp, g_object_unref);
+ g_slist_free_full (items_req, g_object_unref);
}
cache_file = ews_data_cache_get_filename (
diff --git a/src/EWS/common/e-ews-connection.h b/src/EWS/common/e-ews-connection.h
index a3321cbc..3ad44bea 100644
--- a/src/EWS/common/e-ews-connection.h
+++ b/src/EWS/common/e-ews-connection.h
@@ -98,13 +98,6 @@ typedef enum {
EWS_SPECIFIED_OCCURRENCE_ONLY
} EwsAffectedTaskOccurrencesType;
-typedef enum {
- E_EWS_BODY_TYPE_ANY,
- E_EWS_BODY_TYPE_BEST,
- E_EWS_BODY_TYPE_HTML,
- E_EWS_BODY_TYPE_TEXT
-} EEwsBodyType;
-
typedef enum {
E_EWS_SIZE_REQUESTED_UNKNOWN = 0,
E_EWS_SIZE_REQUESTED_48X48 = 48,
diff --git a/src/EWS/common/e-ews-item.c b/src/EWS/common/e-ews-item.c
index 4df2d970..73a82fd4 100644
--- a/src/EWS/common/e-ews-item.c
+++ b/src/EWS/common/e-ews-item.c
@@ -95,6 +95,7 @@ struct _EEwsItemPrivate {
gchar *subject;
gchar *mime_content;
gchar *body;
+ EEwsBodyType body_type;
gchar *date_header;
time_t date_received;
@@ -276,6 +277,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->body_type = E_EWS_BODY_TYPE_ANY;
item->priv->is_meeting = FALSE;
item->priv->is_response_requested = FALSE;
@@ -1645,7 +1647,18 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item,
} else if (!g_ascii_strcasecmp (name, "EndTimeZone")) {
priv->end_timezone = e_soap_parameter_get_property (subparam, "Id");
} else if (!g_ascii_strcasecmp (name, "Body")) {
+ const gchar *body_type;
+
priv->body = e_soap_parameter_get_string_value (subparam);
+
+ body_type = e_soap_parameter_get_property (subparam, "BodyType");
+
+ if (g_strcmp0 (body_type, "HTML") == 0)
+ priv->body_type = E_EWS_BODY_TYPE_HTML;
+ else if (g_strcmp0 (body_type, "Text") == 0)
+ priv->body_type = E_EWS_BODY_TYPE_TEXT;
+ else
+ priv->body_type = E_EWS_BODY_TYPE_ANY;
}
}
@@ -2768,6 +2781,17 @@ e_ews_item_get_body (EEwsItem *item)
return item->priv->task_fields ? item->priv->task_fields->body : NULL;
}
+EEwsBodyType
+e_ews_item_get_body_type (EEwsItem *item)
+{
+ g_return_val_if_fail (E_IS_EWS_ITEM (item), E_EWS_BODY_TYPE_ANY);
+
+ if (item->priv->body)
+ return item->priv->body_type;
+
+ return E_EWS_BODY_TYPE_ANY;
+}
+
const gchar *
e_ews_item_get_owner (EEwsItem *item)
{
diff --git a/src/EWS/common/e-ews-item.h b/src/EWS/common/e-ews-item.h
index 6505fa51..fde46528 100644
--- a/src/EWS/common/e-ews-item.h
+++ b/src/EWS/common/e-ews-item.h
@@ -23,6 +23,13 @@ typedef struct _EEwsItem EEwsItem;
typedef struct _EEwsItemClass EEwsItemClass;
typedef struct _EEwsItemPrivate EEwsItemPrivate;
+typedef enum {
+ E_EWS_BODY_TYPE_ANY,
+ E_EWS_BODY_TYPE_BEST,
+ E_EWS_BODY_TYPE_HTML,
+ E_EWS_BODY_TYPE_TEXT
+} EEwsBodyType;
+
typedef enum {
E_EWS_ITEM_TYPE_UNKNOWN,
E_EWS_ITEM_TYPE_MESSAGE,
@@ -418,6 +425,7 @@ const gchar * e_ews_item_get_status (EEwsItem *item);
const gchar * e_ews_item_get_percent_complete (EEwsItem *item);
const gchar * e_ews_item_get_sensitivity (EEwsItem *item);
const gchar * e_ews_item_get_body (EEwsItem *item);
+EEwsBodyType e_ews_item_get_body_type (EEwsItem *item);
const gchar * e_ews_item_get_owner (EEwsItem *item);
const gchar * e_ews_item_get_delegator (EEwsItem *item);
time_t e_ews_item_get_due_date (EEwsItem *item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]