[evolution-ews/wip/mcrha/soup3] Make the EWS part buildable (untested)
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/wip/mcrha/soup3] Make the EWS part buildable (untested)
- Date: Fri, 17 Dec 2021 11:54:16 +0000 (UTC)
commit 5985c606c3a126de62cfc3ce247e520bb79691a8
Author: Milan Crha <mcrha redhat com>
Date: Fri Dec 17 12:53:40 2021 +0100
Make the EWS part buildable (untested)
CMakeLists.txt | 3 +-
src/CMakeLists.txt | 2 +-
src/EWS/addressbook/e-book-backend-ews.c | 172 ++-
src/EWS/calendar/e-cal-backend-ews-utils.c | 617 ++++++-----
src/EWS/camel/camel-ews-folder.c | 86 +-
src/EWS/camel/camel-ews-store.c | 2 +-
src/EWS/camel/camel-ews-utils.c | 2 +-
src/EWS/common/CMakeLists.txt | 2 -
src/EWS/common/e-ews-camel-common.c | 2 +-
src/EWS/common/e-ews-connection-utils.c | 316 +-----
src/EWS/common/e-ews-connection-utils.h | 9 -
src/EWS/common/e-ews-connection.c | 1126 ++++++++++++--------
src/EWS/common/e-ews-connection.h | 26 +-
src/EWS/common/e-ews-folder.c | 12 +-
src/EWS/common/e-ews-folder.h | 6 +-
src/EWS/common/e-ews-item-change.c | 104 +-
src/EWS/common/e-ews-item.c | 2 +-
src/EWS/common/e-ews-notification.c | 444 ++------
src/EWS/common/e-ews-notification.h | 3 +
src/EWS/common/e-ews-oof-settings.c | 2 +-
src/EWS/common/e-ews-query-to-restriction.c | 2 +-
src/EWS/common/e-ews-request.c | 12 +-
src/EWS/common/e-ews-request.h | 3 +-
src/EWS/common/e-soap-request.c | 192 ++--
src/EWS/common/e-soap-request.h | 40 +-
src/EWS/common/e-soap-response.c | 78 +-
src/EWS/common/e-soap-response.h | 3 +-
src/EWS/common/e-soup-auth-negotiate.c | 342 ------
src/EWS/common/e-soup-auth-negotiate.h | 30 -
src/EWS/evolution/e-ews-config-lookup.c | 8 +-
src/EWS/evolution/e-ews-photo-source.c | 157 +--
src/EWS/evolution/e-mail-config-ews-autodiscover.c | 6 +-
.../evolution/e-mail-config-ews-delegates-page.c | 213 ++--
.../evolution/e-mail-config-ews-oal-combo-box.c | 2 +-
src/EWS/evolution/e-mail-config-ews-ooo-page.c | 2 +-
35 files changed, 1574 insertions(+), 2454 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 375ab40d..3fb05c30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -287,5 +287,6 @@ add_subdirectory(po)
add_subdirectory(src)
if(ENABLE_TESTS)
- add_subdirectory(tests)
+ message(WARNING "tests are disabled until uhttpmock is ported to libsoup3")
+ #add_subdirectory(tests)
endif(ENABLE_TESTS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 78da6ab6..32df2977 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,2 +1,2 @@
add_subdirectory(EWS)
-#add_subdirectory(Microsoft365)
+add_subdirectory(Microsoft365)
diff --git a/src/EWS/addressbook/e-book-backend-ews.c b/src/EWS/addressbook/e-book-backend-ews.c
index 1459c391..9a06a39d 100644
--- a/src/EWS/addressbook/e-book-backend-ews.c
+++ b/src/EWS/addressbook/e-book-backend-ews.c
@@ -772,9 +772,9 @@ ebews_set_cert (EBookBackendEws *bbews,
if (!base64_data)
return;
- e_soap_request_start_element (message, kind, NULL, NULL);
- e_ews_request_write_string_parameter (message, "Base64Binary", NULL, base64_data);
- e_soap_request_end_element (message);
+ e_soap_request_start_element (request, kind, NULL, NULL);
+ e_ews_request_write_string_parameter (request, "Base64Binary", NULL, base64_data);
+ e_soap_request_end_element (request);
}
static void
@@ -782,7 +782,7 @@ ebews_set_user_cert (EBookBackendEws *bbews,
ESoapRequest *request,
EContact *contact)
{
- ebews_set_cert (bbews, message, contact, E_EWS_CERT_KIND_USER, 0);
+ ebews_set_cert (bbews, request, contact, E_EWS_CERT_KIND_USER, 0);
}
@@ -791,7 +791,7 @@ ebews_set_msex_cert (EBookBackendEws *bbews,
ESoapRequest *request,
EContact *contact)
{
- ebews_set_cert (bbews, message, contact, E_EWS_CERT_KIND_MSEX, 1);
+ ebews_set_cert (bbews, request, contact, E_EWS_CERT_KIND_MSEX, 1);
}
static void
@@ -805,7 +805,7 @@ ebews_set_cert_changes (EBookBackendEws *bbews,
const gchar *new_base64_data, *old_base64_data;
/* The first pass */
- if (!message)
+ if (!request)
return;
/* Support for certificates was added in Exchange 2010 SP2. */
@@ -820,13 +820,13 @@ ebews_set_cert_changes (EBookBackendEws *bbews,
return;
if (new_base64_data) {
- e_ews_request_start_set_item_field (message, kind, "contacts", "Contact");
- e_soap_request_start_element (message, kind, NULL, NULL);
- e_ews_request_write_string_parameter (message, "Base64Binary", NULL, new_base64_data);
- e_soap_request_end_element (message);
- e_ews_request_end_set_item_field (message);
+ e_ews_request_start_set_item_field (request, kind, "contacts", "Contact");
+ e_soap_request_start_element (request, kind, NULL, NULL);
+ e_ews_request_write_string_parameter (request, "Base64Binary", NULL, new_base64_data);
+ e_soap_request_end_element (request);
+ e_ews_request_end_set_item_field (request);
} else {
- e_ews_request_add_delete_item_field (message, kind, "contacts");
+ e_ews_request_add_delete_item_field (request, kind, "contacts");
}
}
@@ -839,7 +839,7 @@ ebews_set_user_cert_changes (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_set_cert_changes (bbews, message, new, old, E_EWS_CERT_KIND_USER, 0);
+ ebews_set_cert_changes (bbews, request, new, old, E_EWS_CERT_KIND_USER, 0);
}
static void
@@ -851,7 +851,7 @@ ebews_set_msex_cert_changes (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_set_cert_changes (bbews, message, new, old, E_EWS_CERT_KIND_MSEX, 1);
+ ebews_set_cert_changes (bbews, request, new, old, E_EWS_CERT_KIND_MSEX, 1);
}
static void
@@ -1063,7 +1063,7 @@ ebews_set_date_value (ESoapRequest *request,
value = g_strdup_printf ("%04d-%02d-%02dT00:00:00Z",
date->year, date->month, date->day);
- e_ews_request_write_string_parameter (message, element_name, NULL, value);
+ e_ews_request_write_string_parameter (request, element_name, NULL, value);
e_contact_date_free (date);
g_free (value);
@@ -1074,7 +1074,7 @@ ebews_set_birth_date (EBookBackendEws *bbews,
ESoapRequest *request,
EContact *contact)
{
- ebews_set_date_value (message, contact, E_CONTACT_BIRTH_DATE, "Birthday");
+ ebews_set_date_value (request, contact, E_CONTACT_BIRTH_DATE, "Birthday");
}
static void
@@ -1082,7 +1082,7 @@ ebews_set_anniversary (EBookBackendEws *bbews,
ESoapRequest *request,
EContact *contact)
{
- ebews_set_date_value (message, contact, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
+ ebews_set_date_value (request, contact, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
}
static void
@@ -1249,15 +1249,14 @@ convert_indexed_contact_property_to_updatexml (ESoapRequest *request,
if (!value || !*value)
delete_field = TRUE;
- e_ews_request_start_set_indexed_item_field (message, name , prefix, "Contact", key, delete_field);
+ e_ews_request_start_set_indexed_item_field (request, name , prefix, "Contact", key, delete_field);
- if (!delete_field)
- {
- e_soap_request_start_element (message, element_name, NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (message, "Entry", NULL, value, "Key",
key);
- e_soap_request_end_element (message);
+ if (!delete_field) {
+ e_soap_request_start_element (request, element_name, NULL, NULL);
+ e_ews_request_write_string_parameter_with_attribute (request, "Entry", NULL, value, "Key",
key);
+ e_soap_request_end_element (request);
}
- e_ews_request_end_set_indexed_item_field (message, delete_field);
+ e_ews_request_end_set_indexed_item_field (request, delete_field);
}
static void
@@ -1271,7 +1270,7 @@ ebews_set_full_name_changes (EBookBackendEws *bbews,
{
EContactName *name, *old_name;
- if (!message)
+ if (!request)
return;
name = e_contact_get (new, E_CONTACT_NAME);
@@ -1280,17 +1279,17 @@ ebews_set_full_name_changes (EBookBackendEws *bbews,
return;
if (!old_name) {
- convert_contact_property_to_updatexml (message, "GivenName", name->given, "contacts", NULL,
NULL);
- convert_contact_property_to_updatexml (message, "MiddleName", name->additional, "contacts",
NULL, NULL);
+ convert_contact_property_to_updatexml (request, "GivenName", name->given, "contacts", NULL,
NULL);
+ convert_contact_property_to_updatexml (request, "MiddleName", name->additional, "contacts",
NULL, NULL);
} else if (!name) {
- convert_contact_property_to_updatexml (message, "GivenName", "", "contacts", NULL, NULL);
+ convert_contact_property_to_updatexml (request, "GivenName", "", "contacts", NULL, NULL);
- convert_contact_property_to_updatexml (message, "MiddleName", "", "contacts", NULL, NULL);
+ convert_contact_property_to_updatexml (request, "MiddleName", "", "contacts", NULL, NULL);
} else {
if (g_strcmp0 (name->given, old_name->given) != 0)
- convert_contact_property_to_updatexml (message, "GivenName", name->given, "contacts",
NULL, NULL);
+ convert_contact_property_to_updatexml (request, "GivenName", name->given, "contacts",
NULL, NULL);
if (g_strcmp0 (name->additional, old_name->additional) != 0)
- convert_contact_property_to_updatexml (message, "MiddleName", name->additional,
"contacts", NULL, NULL);
+ convert_contact_property_to_updatexml (request, "MiddleName", name->additional,
"contacts", NULL, NULL);
}
e_contact_name_free (name);
@@ -1307,7 +1306,7 @@ ebews_set_date_value_changes (ESoapRequest *request,
{
EContactDate *new_date, *old_date;
- if (!message)
+ if (!request)
return;
new_date = e_contact_get (new, field);
@@ -1320,11 +1319,11 @@ ebews_set_date_value_changes (ESoapRequest *request,
value = g_strdup_printf ("%04d-%02d-%02dT00:00:00Z",
new_date->year, new_date->month, new_date->day);
- convert_contact_property_to_updatexml (message, element_name, value, "contacts",
NULL, NULL);
+ convert_contact_property_to_updatexml (request, element_name, value, "contacts",
NULL, NULL);
g_free (value);
} else {
- e_ews_request_add_delete_item_field (message, element_name, "contacts");
+ e_ews_request_add_delete_item_field (request, element_name, "contacts");
}
}
@@ -1341,7 +1340,7 @@ ebews_set_birth_date_changes (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_set_date_value_changes (message, new, old, E_CONTACT_BIRTH_DATE, "Birthday");
+ ebews_set_date_value_changes (request, new, old, E_CONTACT_BIRTH_DATE, "Birthday");
}
static void
@@ -1353,7 +1352,7 @@ ebews_set_anniversary_changes (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- ebews_set_date_value_changes (message, new, old, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
+ ebews_set_date_value_changes (request, new, old, E_CONTACT_ANNIVERSARY, "WeddingAnniversary");
}
static void
@@ -1494,7 +1493,7 @@ ebews_set_photo_changes (EBookBackendEws *bbews,
return;
}
- if (message) {
+ if (request) {
/* Photo changes can be done only in pre-flight stage,
because it modifies ChangeKey */
return;
@@ -1589,7 +1588,7 @@ ebews_set_phone_number_changes (EBookBackendEws *bbews,
gint i;
gchar *new_value, *old_value;
- if (!message)
+ if (!request)
return;
for (i = 0; i < G_N_ELEMENTS (phone_field_map); i++) {
@@ -1597,7 +1596,7 @@ ebews_set_phone_number_changes (EBookBackendEws *bbews,
old_value = e_contact_get (old, phone_field_map[i].field);
if (g_strcmp0 (new_value, old_value) != 0)
- convert_indexed_contact_property_to_updatexml (message, "PhoneNumber", new_value,
"contacts", "PhoneNumbers", phone_field_map[i].element);
+ convert_indexed_contact_property_to_updatexml (request, "PhoneNumber", new_value,
"contacts", "PhoneNumbers", phone_field_map[i].element);
g_free (new_value);
g_free (old_value);
@@ -1621,20 +1620,19 @@ convert_indexed_contact_property_to_updatexml_physical_address (ESoapRequest *re
fielduri = g_strconcat (name, ":", uri_element, NULL);
- e_ews_request_start_set_indexed_item_field (message, fielduri , prefix, "Contact", key, delete_field);
+ e_ews_request_start_set_indexed_item_field (request, fielduri , prefix, "Contact", key, delete_field);
- if (!delete_field)
- {
- e_soap_request_start_element (message, element_name, NULL, NULL);
+ if (!delete_field) {
+ e_soap_request_start_element (request, element_name, NULL, NULL);
- e_soap_request_start_element (message, "Entry", NULL, NULL);
- e_soap_request_add_attribute (message, "Key", key, NULL, NULL);
- e_ews_request_write_string_parameter (message, uri_element, NULL, value);
- e_soap_request_end_element (message);
+ e_soap_request_start_element (request, "Entry", NULL, NULL);
+ e_soap_request_add_attribute (request, "Key", key, NULL, NULL);
+ e_ews_request_write_string_parameter (request, uri_element, NULL, value);
+ e_soap_request_end_element (request);
- e_soap_request_end_element (message);
+ e_soap_request_end_element (request);
}
- e_ews_request_end_set_indexed_item_field (message, delete_field);
+ e_ews_request_end_set_indexed_item_field (request, delete_field);
}
static void
@@ -1663,15 +1661,15 @@ compare_address (ESoapRequest *request,
}
if (set || g_strcmp0 (new_address->street, old_address->street) != 0)
- convert_indexed_contact_property_to_updatexml_physical_address (message, "PhysicalAddress",
"Street", new_address->street, "contacts", "PhysicalAddresses", key);
+ convert_indexed_contact_property_to_updatexml_physical_address (request, "PhysicalAddress",
"Street", new_address->street, "contacts", "PhysicalAddresses", key);
if (set || g_strcmp0 (new_address->locality, old_address->locality) != 0)
- convert_indexed_contact_property_to_updatexml_physical_address (message, "PhysicalAddress",
"City", new_address->locality, "contacts", "PhysicalAddresses", key);
+ convert_indexed_contact_property_to_updatexml_physical_address (request, "PhysicalAddress",
"City", new_address->locality, "contacts", "PhysicalAddresses", key);
if (set || g_strcmp0 (new_address->region, old_address->region) != 0)
- convert_indexed_contact_property_to_updatexml_physical_address (message, "PhysicalAddress",
"State", new_address->region, "contacts", "PhysicalAddresses", key);
+ convert_indexed_contact_property_to_updatexml_physical_address (request, "PhysicalAddress",
"State", new_address->region, "contacts", "PhysicalAddresses", key);
if (set || g_strcmp0 (new_address->country, old_address->country) != 0)
- convert_indexed_contact_property_to_updatexml_physical_address (message, "PhysicalAddress",
"CountryOrRegion", new_address->country, "contacts", "PhysicalAddresses", key);
+ convert_indexed_contact_property_to_updatexml_physical_address (request, "PhysicalAddress",
"CountryOrRegion", new_address->country, "contacts", "PhysicalAddresses", key);
if (set || g_strcmp0 (new_address->code, old_address->code) != 0)
- convert_indexed_contact_property_to_updatexml_physical_address (message, "PhysicalAddress",
"PostalCode", new_address->code, "contacts", "PhysicalAddresses", key);
+ convert_indexed_contact_property_to_updatexml_physical_address (request, "PhysicalAddress",
"PostalCode", new_address->code, "contacts", "PhysicalAddresses", key);
e_contact_address_free (old_address);
e_contact_address_free (new_address);
@@ -1686,12 +1684,12 @@ ebews_set_address_changes (EBookBackendEws *bbews,
GCancellable *cancellable,
GError **error)
{
- if (!message)
+ if (!request)
return;
- compare_address (message, new, old, E_CONTACT_ADDRESS_WORK, "Business");
- compare_address (message, new, old, E_CONTACT_ADDRESS_HOME, "Home");
- compare_address (message, new, old, E_CONTACT_ADDRESS_OTHER, "Other");
+ compare_address (request, new, old, E_CONTACT_ADDRESS_WORK, "Business");
+ compare_address (request, new, old, E_CONTACT_ADDRESS_HOME, "Home");
+ compare_address (request, new, old, E_CONTACT_ADDRESS_OTHER, "Other");
}
static void
@@ -1717,7 +1715,7 @@ ebews_set_notes_changes (EBookBackendEws *bbews,
{
gchar *old_notes, *new_notes;
- if (!message)
+ if (!request)
return;
old_notes = e_contact_get (old, E_CONTACT_NOTE);
@@ -1725,7 +1723,7 @@ ebews_set_notes_changes (EBookBackendEws *bbews,
if (g_strcmp0 (old_notes, new_notes) != 0) {
convert_contact_property_to_updatexml (
- message, "Body", new_notes ? new_notes : "", "item", "BodyType", "Text");
+ request, "Body", new_notes ? new_notes : "", "item", "BodyType", "Text");
}
g_free (old_notes);
@@ -1743,27 +1741,27 @@ ebews_set_email_changes (EBookBackendEws *bbews,
{
gchar *new_value, *old_value;
- if (!message)
+ if (!request)
return;
new_value = e_contact_get (new, E_CONTACT_EMAIL_1);
old_value = e_contact_get (old, E_CONTACT_EMAIL_1);
if (g_strcmp0 (new_value, old_value) != 0)
- convert_indexed_contact_property_to_updatexml (message, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress1");
+ convert_indexed_contact_property_to_updatexml (request, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress1");
g_free (new_value);
g_free (old_value);
new_value = e_contact_get (new, E_CONTACT_EMAIL_2);
old_value = e_contact_get (old, E_CONTACT_EMAIL_2);
if (g_strcmp0 (new_value, old_value) != 0)
- convert_indexed_contact_property_to_updatexml (message, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress2");
+ convert_indexed_contact_property_to_updatexml (request, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress2");
g_free (new_value);
g_free (old_value);
new_value = e_contact_get (new, E_CONTACT_EMAIL_3);
old_value = e_contact_get (old, E_CONTACT_EMAIL_3);
if (g_strcmp0 (new_value, old_value) != 0)
- convert_indexed_contact_property_to_updatexml (message, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress3");
+ convert_indexed_contact_property_to_updatexml (request, "EmailAddress", new_value,
"contacts", "EmailAddresses", "EmailAddress3");
g_free (new_value);
g_free (old_value);
}
@@ -1846,13 +1844,13 @@ ebews_set_categories (EBookBackendEws *bbews,
if (values) {
GList *link;
- e_soap_request_start_element (message, "Categories", NULL, NULL);
+ e_soap_request_start_element (request, "Categories", NULL, NULL);
for (link = values; link; link = g_list_next (link)) {
const gchar *category = link->data;
if (category && *category)
- e_ews_request_write_string_parameter (message, "String", NULL, category);
+ e_ews_request_write_string_parameter (request, "String", NULL, category);
}
- e_soap_request_end_element (message);
+ e_soap_request_end_element (request);
}
g_list_free_full (values, g_free);
@@ -1869,7 +1867,7 @@ ebews_set_categories_changes (EBookBackendEws *bbews,
{
gchar *old_categories, *new_categories;
- if (!message)
+ if (!request)
return;
old_categories = e_contact_get (old, E_CONTACT_CATEGORIES);
@@ -1880,27 +1878,27 @@ ebews_set_categories_changes (EBookBackendEws *bbews,
values = e_contact_get (new, E_CONTACT_CATEGORY_LIST);
if (values) {
- e_soap_request_start_element (message, "SetItemField", NULL, NULL);
+ e_soap_request_start_element (request, "SetItemField", NULL, NULL);
- e_soap_request_start_element (message, "FieldURI", NULL, NULL);
- e_soap_request_add_attribute (message, "FieldURI", "item:Categories", NULL, NULL);
- e_soap_request_end_element (message);
+ e_soap_request_start_element (request, "FieldURI", NULL, NULL);
+ e_soap_request_add_attribute (request, "FieldURI", "item:Categories", NULL, NULL);
+ e_soap_request_end_element (request);
- e_soap_request_start_element (message, "Contact", NULL, NULL);
- e_soap_request_start_element (message, "Categories", NULL, NULL);
+ e_soap_request_start_element (request, "Contact", NULL, NULL);
+ e_soap_request_start_element (request, "Categories", NULL, NULL);
for (link = values; link; link = g_list_next (link)) {
const gchar *category = link->data;
if (category && *category)
- e_ews_request_write_string_parameter (message, "String", NULL,
category);
+ e_ews_request_write_string_parameter (request, "String", NULL,
category);
}
- e_soap_request_end_element (message); /* Categories */
- e_soap_request_end_element (message); /* Contact */
- e_soap_request_end_element (message); /* SetItemField */
+ e_soap_request_end_element (request); /* Categories */
+ e_soap_request_end_element (request); /* Contact */
+ e_soap_request_end_element (request); /* SetItemField */
} else {
- e_ews_request_add_delete_item_field (message, "Categories", "item");
+ e_ews_request_add_delete_item_field (request, "Categories", "item");
}
g_list_free_full (values, g_free);
@@ -1917,7 +1915,7 @@ static const struct field_element_mapping {
/* set function for simple string type values */
const gchar * (*get_simple_prop_func) (EEwsItem *item);
void (*populate_contact_func)(EBookBackendEws *bbews, EContact *contact, EEwsItem *item, GCancellable
*cancellable, GError **error);
- void (*set_value_in_soap_message) (EBookBackendEws *bbews, ESoapRequest *request, EContact *contact);
+ void (*set_value_in_soap_request) (EBookBackendEws *bbews, ESoapRequest *request, EContact *contact);
void (*set_changes) (EBookBackendEws *bbews, ESoapRequest *request, EContact *new, EContact *old,
gchar **out_new_change_key, GCancellable *cancellable, GError **error);
} mappings[] = {
@@ -2007,7 +2005,7 @@ ebb_ews_convert_dl_to_xml_cb (ESoapRequest *request,
EVCardAttribute *attribute;
GList *values;
- /* Prepare DistributionList node in the SOAP message */
+ /* Prepare DistributionList node in the SOAP request */
e_soap_request_start_element (request, "DistributionList", NULL, NULL);
attribute = e_vcard_get_attribute (E_VCARD (contact), EVC_FN);
@@ -2030,7 +2028,7 @@ ebb_ews_convert_contact_to_xml_cb (ESoapRequest *request,
EContact *contact = cid->contact;
gint i, element_type;
- /* Prepare Contact node in the SOAP message */
+ /* Prepare Contact node in the SOAP request */
e_soap_request_start_element (request, "Contact", NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (mappings); i++) {
@@ -2048,7 +2046,7 @@ ebb_ews_convert_contact_to_xml_cb (ESoapRequest *request,
e_ews_request_write_string_parameter (request, mappings[i].element_name,
NULL, val);
g_free (val);
} else
- mappings[i].set_value_in_soap_message (cid->bbews, request, contact);
+ mappings[i].set_value_in_soap_request (cid->bbews, request, contact);
}
/* end of "Contact" */
@@ -2298,8 +2296,8 @@ ebb_ews_traverse_dl (EBookBackendEws *bbews,
bbews->priv->cnc,
EWS_PRIORITY_MEDIUM,
mb,
- &members,
&includes_last,
+ &members,
cancellable,
&local_error);
@@ -2503,8 +2501,8 @@ ebb_ews_fetch_items_sync (EBookBackendEws *bbews,
d_name = e_ews_item_get_subject (item);
if (e_ews_connection_expand_dl_sync (
- bbews->priv->cnc, EWS_PRIORITY_MEDIUM, mb, &members,
- &includes_last, cancellable, &local_error)) {
+ bbews->priv->cnc, EWS_PRIORITY_MEDIUM, mb, &includes_last, &members,
+ cancellable, &local_error)) {
ret = ebb_ews_contacts_append_dl (bbews, item, id, d_name, members, contacts,
cancellable, error);
g_slist_free_full (members, (GDestroyNotify) e_ews_mailbox_free);
} else {
@@ -3999,7 +3997,7 @@ ebb_ews_get_changes_sync (EBookMetaBackend *meta_backend,
d (printf ("Ewsgal: Fetching oal full details file\n"));
if (!e_ews_connection_get_oal_detail_sync (oab_cnc, bbews->priv->folder_id, NULL,
last_sync_tag, &full_l, &etag, cancellable, &local_error)) {
- if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_NOT_MODIFIED))
{
+ if (g_error_matches (local_error, E_SOUP_SESSION_ERROR,
SOUP_STATUS_NOT_MODIFIED)) {
g_clear_error (&local_error);
} else {
success = FALSE;
diff --git a/src/EWS/calendar/e-cal-backend-ews-utils.c b/src/EWS/calendar/e-cal-backend-ews-utils.c
index f2386930..06ebca9d 100644
--- a/src/EWS/calendar/e-cal-backend-ews-utils.c
+++ b/src/EWS/calendar/e-cal-backend-ews-utils.c
@@ -27,7 +27,6 @@
#include <libxml/xpathInternals.h>
#include <libecal/libecal.h>
-#include <libsoup/soup-misc.h>
#include "common/e-ews-calendar-utils.h"
#include "common/e-ews-connection.h"
@@ -346,7 +345,7 @@ ews_set_alarm (ESoapRequest *request,
alarm = e_cal_component_get_alarm (comp, (const gchar *) (alarm_uids->data));
- e_ews_request_write_string_parameter (msg, "ReminderIsSet", NULL, "true");
+ e_ews_request_write_string_parameter (request, "ReminderIsSet", NULL, "true");
action = e_cal_component_alarm_get_action (alarm);
if (action == E_CAL_COMPONENT_ALARM_DISPLAY) {
ECalComponentAlarmTrigger *trigger;
@@ -355,7 +354,7 @@ ews_set_alarm (ESoapRequest *request,
trigger = e_cal_component_alarm_get_trigger (alarm);
if (trigger && e_cal_component_alarm_trigger_get_kind (trigger) ==
E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) {
dur_int = (i_cal_duration_as_int (e_cal_component_alarm_trigger_get_duration
(trigger)) / SECS_IN_MINUTE) * -1;
- e_ews_request_write_int_parameter (msg, "ReminderMinutesBeforeStart", NULL, dur_int);
+ e_ews_request_write_int_parameter (request, "ReminderMinutesBeforeStart", NULL,
dur_int);
if (with_due_by) {
ICalTime *dtstart;
@@ -363,7 +362,7 @@ ews_set_alarm (ESoapRequest *request,
I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
if (dtstart && !i_cal_time_is_null_time (dtstart)) {
- e_ews_request_write_time_parameter (msg, "ReminderDueBy", NULL,
+ e_ews_request_write_time_parameter (request, "ReminderDueBy", NULL,
i_cal_time_as_timet_with_zone (dtstart,
i_cal_timezone_get_utc_timezone ()));
}
@@ -386,7 +385,7 @@ ewscal_set_date (ESoapRequest *request,
"%04d-%02d-%02d",
i_cal_time_get_year (itt), i_cal_time_get_month (itt), i_cal_time_get_day (itt));
- e_ews_request_write_string_parameter (msg, name, NULL, str);
+ e_ews_request_write_string_parameter (request, name, NULL, str);
g_free (str);
}
@@ -437,13 +436,13 @@ ewscal_add_rrule (ESoapRequest *request,
{
ICalRecurrence *recur = i_cal_property_get_rrule (prop);
- e_soap_request_start_element (msg, "RelativeYearlyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "RelativeYearlyRecurrence", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "DaysOfWeek", NULL, number_to_weekday
(i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (recur, 0))));
- e_ews_request_write_string_parameter (msg, "DayOfWeekIndex", NULL, weekindex_to_ical
(i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (recur, 0))));
- e_ews_request_write_string_parameter (msg, "Month", NULL, number_to_month
(i_cal_recurrence_get_by_month (recur, 0)));
+ e_ews_request_write_string_parameter (request, "DaysOfWeek", NULL, number_to_weekday
(i_cal_recurrence_day_day_of_week (i_cal_recurrence_get_by_day (recur, 0))));
+ e_ews_request_write_string_parameter (request, "DayOfWeekIndex", NULL, weekindex_to_ical
(i_cal_recurrence_day_position (i_cal_recurrence_get_by_day (recur, 0))));
+ e_ews_request_write_string_parameter (request, "Month", NULL, number_to_month
(i_cal_recurrence_get_by_month (recur, 0)));
- e_soap_request_end_element (msg); /* "RelativeYearlyRecurrence" */
+ e_soap_request_end_element (request); /* "RelativeYearlyRecurrence" */
g_clear_object (&recur);
}
@@ -461,7 +460,7 @@ ewscal_add_timechange (ESoapRequest *request,
prop = i_cal_component_get_first_property (comp, I_CAL_TZNAME_PROPERTY);
if (prop) {
tzname = i_cal_property_get_tzname (prop);
- e_soap_request_add_attribute (msg, "TimeZoneName", tzname, NULL, NULL);
+ e_soap_request_add_attribute (request, "TimeZoneName", tzname, NULL, NULL);
g_object_unref (prop);
}
@@ -474,7 +473,7 @@ ewscal_add_timechange (ESoapRequest *request,
utcoffs -= baseoffs;
duration = i_cal_duration_new_from_int (utcoffs);
offset = i_cal_duration_as_ical_string (duration);
- e_ews_request_write_string_parameter (msg, "Offset", NULL, offset);
+ e_ews_request_write_string_parameter (request, "Offset", NULL, offset);
g_clear_object (&duration);
g_object_unref (prop);
@@ -483,7 +482,7 @@ ewscal_add_timechange (ESoapRequest *request,
prop = i_cal_component_get_first_property (comp, I_CAL_RRULE_PROPERTY);
if (prop) {
- ewscal_add_rrule (msg, prop);
+ ewscal_add_rrule (request, prop);
g_object_unref (prop);
}
@@ -491,7 +490,7 @@ ewscal_add_timechange (ESoapRequest *request,
if (prop) {
dtstart = i_cal_property_get_dtstart (prop);
snprintf (buffer, 16, "%02d:%02d:%02d", i_cal_time_get_hour (dtstart), i_cal_time_get_minute
(dtstart), i_cal_time_get_second (dtstart));
- e_ews_request_write_string_parameter (msg, "Time", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "Time", NULL, buffer);
g_clear_object (&dtstart);
g_object_unref (prop);
}
@@ -509,15 +508,14 @@ ewscal_set_absolute_date_transitions (ESoapRequest *request,
for (l = absolute_date_transitions; l != NULL; l = l->next) {
EEwsCalendarAbsoluteDateTransition *adt = l->data;
- e_soap_request_start_element (msg, "AbsoluteDateTransition", NULL, NULL);
+ e_soap_request_start_element (request, "AbsoluteDateTransition", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg,
+ e_ews_request_write_string_parameter_with_attribute (request,
"To", NULL, adt->to->value,
"Kind", adt->to->kind);
- e_ews_request_write_string_parameter (msg, "DateTime", NULL, adt->date_time);
+ e_ews_request_write_string_parameter (request, "DateTime", NULL, adt->date_time);
- e_soap_request_end_element (msg); /* "AbsoluteDateTransition" */
+ e_soap_request_end_element (request); /* "AbsoluteDateTransition" */
}
}
@@ -533,18 +531,17 @@ ewscal_set_recurring_day_transitions (ESoapRequest *request,
for (l = recurring_day_transitions; l != NULL; l = l->next) {
EEwsCalendarRecurringDayTransition *rdt = l->data;
- e_soap_request_start_element (msg, "RecurringDayTransition", NULL, NULL);
+ e_soap_request_start_element (request, "RecurringDayTransition", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg,
+ e_ews_request_write_string_parameter_with_attribute (request,
"To", NULL, rdt->to->value,
"Kind", rdt->to->kind);
- e_ews_request_write_string_parameter (msg, "TimeOffset", NULL, rdt->time_offset);
- e_ews_request_write_string_parameter (msg, "Month", NULL, rdt->month);
- e_ews_request_write_string_parameter (msg, "DayOfWeek", NULL, rdt->day_of_week);
- e_ews_request_write_string_parameter (msg, "Occurrence", NULL, rdt->occurrence);
+ e_ews_request_write_string_parameter (request, "TimeOffset", NULL, rdt->time_offset);
+ e_ews_request_write_string_parameter (request, "Month", NULL, rdt->month);
+ e_ews_request_write_string_parameter (request, "DayOfWeek", NULL, rdt->day_of_week);
+ e_ews_request_write_string_parameter (request, "Occurrence", NULL, rdt->occurrence);
- e_soap_request_end_element (msg); /* "RecurringDayTransition" */
+ e_soap_request_end_element (request); /* "RecurringDayTransition" */
}
}
@@ -560,17 +557,16 @@ ewscal_set_recurring_date_transitions (ESoapRequest *request,
for (l = recurring_date_transitions; l != NULL; l = l->next) {
EEwsCalendarRecurringDateTransition *rdt = l->data;
- e_soap_request_start_element (msg, "RecurringDateTransition", NULL, NULL);
+ e_soap_request_start_element (request, "RecurringDateTransition", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg,
+ e_ews_request_write_string_parameter_with_attribute (request,
"To", NULL, rdt->to->value,
"Kind", rdt->to->kind);
- e_ews_request_write_string_parameter (msg, "TimeOffset", NULL, rdt->time_offset);
- e_ews_request_write_string_parameter (msg, "Month", NULL, rdt->month);
- e_ews_request_write_string_parameter (msg, "Day", NULL, rdt->day);
+ e_ews_request_write_string_parameter (request, "TimeOffset", NULL, rdt->time_offset);
+ e_ews_request_write_string_parameter (request, "Month", NULL, rdt->month);
+ e_ews_request_write_string_parameter (request, "Day", NULL, rdt->day);
- e_soap_request_end_element (msg); /* "RecurringDateTransition" */
+ e_soap_request_end_element (request); /* "RecurringDateTransition" */
}
}
@@ -584,59 +580,57 @@ ewscal_set_timezone (ESoapRequest *request,
if (name == NULL || tzd == NULL)
return;
- e_soap_request_start_element (msg, name, NULL, NULL);
- e_soap_request_add_attribute (msg, "Id", tzd->id, NULL, NULL);
- e_soap_request_add_attribute (msg, "Name", tzd->name, NULL, NULL);
+ e_soap_request_start_element (request, name, NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", tzd->id, NULL, NULL);
+ e_soap_request_add_attribute (request, "Name", tzd->name, NULL, NULL);
- e_soap_request_start_element (msg, "Periods", NULL, NULL);
+ e_soap_request_start_element (request, "Periods", NULL, NULL);
for (l = tzd->periods; l != NULL; l = l->next) {
EEwsCalendarPeriod *period = l->data;
- e_soap_request_start_element (msg, "Period", NULL, NULL);
- e_soap_request_add_attribute (msg, "Bias", period->bias, NULL, NULL);
- e_soap_request_add_attribute (msg, "Name", period->name, NULL, NULL);
- e_soap_request_add_attribute (msg, "Id", period->id, NULL, NULL);
- e_soap_request_end_element (msg); /* "Period" */
+ e_soap_request_start_element (request, "Period", NULL, NULL);
+ e_soap_request_add_attribute (request, "Bias", period->bias, NULL, NULL);
+ e_soap_request_add_attribute (request, "Name", period->name, NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", period->id, NULL, NULL);
+ e_soap_request_end_element (request); /* "Period" */
}
- e_soap_request_end_element (msg); /* "Periods" */
+ e_soap_request_end_element (request); /* "Periods" */
- e_soap_request_start_element (msg, "TransitionsGroups", NULL, NULL);
+ e_soap_request_start_element (request, "TransitionsGroups", NULL, NULL);
for (l = tzd->transitions_groups; l != NULL; l = l->next) {
EEwsCalendarTransitionsGroup *tg = l->data;
- e_soap_request_start_element (msg, "TransitionsGroup", NULL, NULL);
- e_soap_request_add_attribute (msg, "Id", tg->id, NULL, NULL);
+ e_soap_request_start_element (request, "TransitionsGroup", NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", tg->id, NULL, NULL);
if (tg->transition != NULL) {
- e_soap_request_start_element (msg, "Transition", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg,
+ e_soap_request_start_element (request, "Transition", NULL, NULL);
+ e_ews_request_write_string_parameter_with_attribute (request,
"To", NULL, tg->transition->value,
"Kind", tg->transition->kind);
- e_soap_request_end_element (msg); /* "Transition" */
+ e_soap_request_end_element (request); /* "Transition" */
}
- ewscal_set_absolute_date_transitions (msg, tg->absolute_date_transitions);
- ewscal_set_recurring_day_transitions (msg, tg->recurring_day_transitions);
- ewscal_set_recurring_date_transitions (msg, tg->recurring_date_transitions);
+ ewscal_set_absolute_date_transitions (request, tg->absolute_date_transitions);
+ ewscal_set_recurring_day_transitions (request, tg->recurring_day_transitions);
+ ewscal_set_recurring_date_transitions (request, tg->recurring_date_transitions);
- e_soap_request_end_element (msg); /* "TransitionsGroup" */
+ e_soap_request_end_element (request); /* "TransitionsGroup" */
}
- e_soap_request_end_element (msg); /* "TransitionsGroups" */
+ e_soap_request_end_element (request); /* "TransitionsGroups" */
- e_soap_request_start_element (msg, "Transitions", NULL, NULL);
- e_soap_request_start_element (msg, "Transition", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg,
+ e_soap_request_start_element (request, "Transitions", NULL, NULL);
+ e_soap_request_start_element (request, "Transition", NULL, NULL);
+ e_ews_request_write_string_parameter_with_attribute (request,
"To", NULL, tzd->transitions->transition->value,
"Kind", tzd->transitions->transition->kind);
- e_soap_request_end_element (msg); /* "Transition" */
- ewscal_set_absolute_date_transitions (msg, tzd->transitions->absolute_date_transitions);
- ewscal_set_recurring_day_transitions (msg, tzd->transitions->recurring_day_transitions);
- ewscal_set_recurring_date_transitions (msg, tzd->transitions->recurring_date_transitions);
- e_soap_request_end_element (msg); /* "Transitions" */
+ e_soap_request_end_element (request); /* "Transition" */
+ ewscal_set_absolute_date_transitions (request, tzd->transitions->absolute_date_transitions);
+ ewscal_set_recurring_day_transitions (request, tzd->transitions->recurring_day_transitions);
+ ewscal_set_recurring_date_transitions (request, tzd->transitions->recurring_date_transitions);
+ e_soap_request_end_element (request); /* "Transitions" */
- e_soap_request_end_element (msg); /* "StartTimeZone" */
+ e_soap_request_end_element (request); /* "StartTimeZone" */
}
void
@@ -688,8 +682,8 @@ ewscal_set_meeting_timezone (ESoapRequest *request,
if (!location)
location = i_cal_timezone_get_tznames (icaltz);
- e_soap_request_start_element (msg, "MeetingTimeZone", NULL, NULL);
- e_soap_request_add_attribute (msg, "TimeZoneName", location, NULL, NULL);
+ e_soap_request_start_element (request, "MeetingTimeZone", NULL, NULL);
+ e_soap_request_add_attribute (request, "TimeZoneName", location, NULL, NULL);
/* Fetch the timezone offsets for the standard (or only) zone.
* Negate it, because Exchange does it backwards */
@@ -710,7 +704,7 @@ ewscal_set_meeting_timezone (ESoapRequest *request,
* zone to zero. So try to avoid problems by doing the same. */
duration = i_cal_duration_new_from_int (std_utcoffs);
offset = i_cal_duration_as_ical_string (duration);
- e_ews_request_write_string_parameter (msg, "BaseOffset", NULL, offset);
+ e_ews_request_write_string_parameter (request, "BaseOffset", NULL, offset);
g_clear_object (&duration);
free (offset);
@@ -719,16 +713,16 @@ ewscal_set_meeting_timezone (ESoapRequest *request,
* one. */
if (xdaylight) {
/* Standard */
- e_soap_request_start_element (msg, "Standard", NULL, NULL);
- ewscal_add_timechange (msg, xstd, std_utcoffs);
- e_soap_request_end_element (msg); /* "Standard" */
+ e_soap_request_start_element (request, "Standard", NULL, NULL);
+ ewscal_add_timechange (request, xstd, std_utcoffs);
+ e_soap_request_end_element (request); /* "Standard" */
/* DayLight */
- e_soap_request_start_element (msg, "Daylight", NULL, NULL);
- ewscal_add_timechange (msg, xdaylight, std_utcoffs);
- e_soap_request_end_element (msg); /* "Daylight" */
+ e_soap_request_start_element (request, "Daylight", NULL, NULL);
+ ewscal_add_timechange (request, xdaylight, std_utcoffs);
+ e_soap_request_end_element (request); /* "Daylight" */
}
- e_soap_request_end_element (msg); /* "MeetingTimeZone" */
+ e_soap_request_end_element (request); /* "MeetingTimeZone" */
g_clear_object (&comp);
g_clear_object (&xstd);
@@ -750,21 +744,21 @@ ewscal_set_reccurence (ESoapRequest *request,
if (!recur)
return;
- e_soap_request_start_element (msg, "Recurrence", NULL, NULL);
+ e_soap_request_start_element (request, "Recurrence", NULL, NULL);
switch (i_cal_recurrence_get_freq (recur)) {
case I_CAL_DAILY_RECURRENCE:
- e_soap_request_start_element (msg, "DailyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "DailyRecurrence", NULL, NULL);
snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
- e_ews_request_write_string_parameter (msg, "Interval", NULL, buffer);
- e_soap_request_end_element (msg); /* "DailyRecurrence" */
+ e_ews_request_write_string_parameter (request, "Interval", NULL, buffer);
+ e_soap_request_end_element (request); /* "DailyRecurrence" */
break;
case I_CAL_WEEKLY_RECURRENCE:
- e_soap_request_start_element (msg, "WeeklyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "WeeklyRecurrence", NULL, NULL);
snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
- e_ews_request_write_string_parameter (msg, "Interval", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "Interval", NULL, buffer);
len = snprintf (
buffer, 256, "%s",
@@ -774,51 +768,50 @@ ewscal_set_reccurence (ESoapRequest *request,
buffer + len, 256 - len, " %s",
number_to_weekday (i_cal_recurrence_day_day_of_week
(i_cal_recurrence_get_by_day (recur, i))));
}
- e_ews_request_write_string_parameter (msg, "DaysOfWeek", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "DaysOfWeek", NULL, buffer);
- e_soap_request_end_element (msg); /* "WeeklyRecurrence" */
+ e_soap_request_end_element (request); /* "WeeklyRecurrence" */
break;
case I_CAL_MONTHLY_RECURRENCE:
if (i_cal_recurrence_get_by_month_day (recur, 0) == I_CAL_RECURRENCE_ARRAY_MAX) {
- e_soap_request_start_element (msg, "RelativeMonthlyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "RelativeMonthlyRecurrence", NULL,
NULL);
/* For now this is what got implemented since this is the only
relative monthly recurrence evolution can set.
TODO: extend the code with all possible monthly recurrence settings */
snprintf (buffer, 32, "%d", i_cal_recurrence_get_interval (recur));
- e_ews_request_write_string_parameter (msg, "Interval", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "Interval", NULL, buffer);
- e_ews_request_write_string_parameter (
- msg, "DaysOfWeek", NULL,
+ e_ews_request_write_string_parameter (request, "DaysOfWeek", NULL,
number_to_weekday (i_cal_recurrence_day_day_of_week
(i_cal_recurrence_get_by_day (recur, 0))));
- e_ews_request_write_string_parameter (msg, "DayOfWeekIndex", NULL,
weekindex_to_ical (
+ e_ews_request_write_string_parameter (request, "DayOfWeekIndex", NULL,
weekindex_to_ical (
i_cal_recurrence_get_by_set_pos (recur, 0) == 5 ? -1 :
i_cal_recurrence_get_by_set_pos (recur, 0)));
- e_soap_request_end_element (msg); /* "RelativeMonthlyRecurrence" */
+ e_soap_request_end_element (request); /* "RelativeMonthlyRecurrence" */
} else {
- e_soap_request_start_element (msg, "AbsoluteMonthlyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "AbsoluteMonthlyRecurrence", NULL,
NULL);
snprintf (buffer, 256, "%d", i_cal_recurrence_get_interval (recur));
- e_ews_request_write_string_parameter (msg, "Interval", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "Interval", NULL, buffer);
snprintf (buffer, 256, "%d", i_cal_recurrence_get_by_month_day (recur, 0) ==
-1 ? 31 : i_cal_recurrence_get_by_month_day (recur, 0));
- e_ews_request_write_string_parameter (msg, "DayOfMonth", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "DayOfMonth", NULL, buffer);
- e_soap_request_end_element (msg); /* "AbsoluteMonthlyRecurrence" */
+ e_soap_request_end_element (request); /* "AbsoluteMonthlyRecurrence" */
}
break;
case I_CAL_YEARLY_RECURRENCE:
#if 0 /* FIXME */
if (is_relative) {
- ewscal_add_rrule (msg, rrule);
+ ewscal_add_rrule (request, rrule);
} else
#endif
{
- e_soap_request_start_element (msg, "AbsoluteYearlyRecurrence", NULL, NULL);
+ e_soap_request_start_element (request, "AbsoluteYearlyRecurrence", NULL,
NULL);
/* work according to RFC5545 ยง3.3.10
* dtstart is the default, give preference to by_month & by_month_day if they
are set
@@ -828,20 +821,18 @@ ewscal_set_reccurence (ESoapRequest *request,
} else {
snprintf (buffer, 256, "%d", i_cal_time_get_day (dtstart));
}
- e_ews_request_write_string_parameter (msg, "DayOfMonth", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "DayOfMonth", NULL, buffer);
if (i_cal_recurrence_get_by_month (recur, 0) != I_CAL_RECURRENCE_ARRAY_MAX) {
snprintf (buffer, 256, "%d", i_cal_recurrence_get_by_month_day
(recur, 0));
- e_ews_request_write_string_parameter (
- msg, "Month", NULL,
+ e_ews_request_write_string_parameter (request, "Month", NULL,
number_to_month (i_cal_recurrence_get_by_month (recur, 0)));
} else {
- e_ews_request_write_string_parameter (
- msg, "Month", NULL,
+ e_ews_request_write_string_parameter (request, "Month", NULL,
number_to_month (i_cal_time_get_month (dtstart)));
}
- e_soap_request_end_element (msg); /* "AbsoluteYearlyRecurrence" */
+ e_soap_request_end_element (request); /* "AbsoluteYearlyRecurrence" */
}
break;
@@ -856,32 +847,32 @@ ewscal_set_reccurence (ESoapRequest *request,
}
if (i_cal_recurrence_get_count (recur) > 0) {
- e_soap_request_start_element (msg, "NumberedRecurrence", NULL, NULL);
- ewscal_set_date (msg, "StartDate", dtstart);
+ e_soap_request_start_element (request, "NumberedRecurrence", NULL, NULL);
+ ewscal_set_date (request, "StartDate", dtstart);
snprintf (buffer, 32, "%d", i_cal_recurrence_get_count (recur));
- e_ews_request_write_string_parameter (msg, "NumberOfOccurrences", NULL, buffer);
- e_soap_request_end_element (msg); /* "NumberedRecurrence" */
+ e_ews_request_write_string_parameter (request, "NumberOfOccurrences", NULL, buffer);
+ e_soap_request_end_element (request); /* "NumberedRecurrence" */
} else {
ICalTime *until;
until = i_cal_recurrence_get_until (recur);
if (until && !i_cal_time_is_null_time (until)) {
- e_soap_request_start_element (msg, "EndDateRecurrence", NULL, NULL);
- ewscal_set_date (msg, "StartDate", dtstart);
- ewscal_set_date (msg, "EndDate", until);
- e_soap_request_end_element (msg); /* "EndDateRecurrence" */
+ e_soap_request_start_element (request, "EndDateRecurrence", NULL, NULL);
+ ewscal_set_date (request, "StartDate", dtstart);
+ ewscal_set_date (request, "EndDate", until);
+ e_soap_request_end_element (request); /* "EndDateRecurrence" */
} else {
- e_soap_request_start_element (msg, "NoEndRecurrence", NULL, NULL);
- ewscal_set_date (msg, "StartDate", dtstart);
- e_soap_request_end_element (msg); /* "NoEndRecurrence" */
+ e_soap_request_start_element (request, "NoEndRecurrence", NULL, NULL);
+ ewscal_set_date (request, "StartDate", dtstart);
+ e_soap_request_end_element (request); /* "NoEndRecurrence" */
}
g_clear_object (&until);
}
exit:
- e_soap_request_end_element (msg); /* "Recurrence" */
+ e_soap_request_end_element (request); /* "Recurrence" */
g_object_unref (recur);
}
@@ -942,21 +933,21 @@ ewscal_set_reccurence_exceptions (ESoapRequest *request,
if (!exdate)
return;
- e_soap_request_start_element (msg, "DeletedOccurrences", NULL, NULL);
+ e_soap_request_start_element (request, "DeletedOccurrences", NULL, NULL);
for (; exdate; g_object_unref (exdate), exdate = i_cal_component_get_next_property (comp,
I_CAL_EXDATE_PROPERTY)) {
ICalTime *exdatetime = icomponent_get_datetime (comp, exdate);
- e_soap_request_start_element (msg, "DeletedOccurrence", NULL, NULL);
+ e_soap_request_start_element (request, "DeletedOccurrence", NULL, NULL);
- ewscal_set_date (msg, "Start", exdatetime);
+ ewscal_set_date (request, "Start", exdatetime);
- e_soap_request_end_element (msg); /* "DeletedOccurrence" */
+ e_soap_request_end_element (request); /* "DeletedOccurrence" */
g_clear_object (&exdatetime);
}
- e_soap_request_end_element (msg); /* "DeletedOccurrences" */
+ e_soap_request_end_element (request); /* "DeletedOccurrences" */
}
/*
@@ -1022,19 +1013,19 @@ add_attendees_list_to_message (ESoapRequest *request,
{
GSList *item;
- e_soap_request_start_element (msg, listname, NULL, NULL);
+ e_soap_request_start_element (request, listname, NULL, NULL);
for (item = list; item != NULL; item = item->next) {
- e_soap_request_start_element (msg, "Attendee", NULL, NULL);
- e_soap_request_start_element (msg, "Mailbox", NULL, NULL);
+ e_soap_request_start_element (request, "Attendee", NULL, NULL);
+ e_soap_request_start_element (request, "Mailbox", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "EmailAddress", NULL, item->data);
+ e_ews_request_write_string_parameter (request, "EmailAddress", NULL, item->data);
- e_soap_request_end_element (msg); /* "Mailbox" */
- e_soap_request_end_element (msg); /* "Attendee" */
+ e_soap_request_end_element (request); /* "Mailbox" */
+ e_soap_request_end_element (request); /* "Attendee" */
}
- e_soap_request_end_element (msg);
+ e_soap_request_end_element (request);
}
static void
@@ -1043,18 +1034,18 @@ convert_sensitivity_calcomp_to_xml (ESoapRequest *request,
{
ICalProperty *prop;
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (icomp != NULL);
prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
if (prop) {
ICalProperty_Class classify = i_cal_property_get_class (prop);
if (classify == I_CAL_CLASS_PUBLIC) {
- e_ews_request_write_string_parameter (msg, "Sensitivity", NULL, "Normal");
+ e_ews_request_write_string_parameter (request, "Sensitivity", NULL, "Normal");
} else if (classify == I_CAL_CLASS_PRIVATE) {
- e_ews_request_write_string_parameter (msg, "Sensitivity", NULL, "Private");
+ e_ews_request_write_string_parameter (request, "Sensitivity", NULL, "Private");
} else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
- e_ews_request_write_string_parameter (msg, "Sensitivity", NULL, "Personal");
+ e_ews_request_write_string_parameter (request, "Sensitivity", NULL, "Personal");
}
g_object_unref (prop);
}
@@ -1067,7 +1058,7 @@ convert_categories_calcomp_to_xml (ESoapRequest *request,
{
GSList *categ_list, *citer;
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (icomp != NULL);
if (comp) {
@@ -1096,7 +1087,7 @@ convert_categories_calcomp_to_xml (ESoapRequest *request,
}
if (citer) {
- e_soap_request_start_element (msg, "Categories", NULL, NULL);
+ e_soap_request_start_element (request, "Categories", NULL, NULL);
for (citer = categ_list; citer; citer = g_slist_next (citer)) {
const gchar *category = citer->data;
@@ -1104,10 +1095,10 @@ convert_categories_calcomp_to_xml (ESoapRequest *request,
if (!category || !*category)
continue;
- e_ews_request_write_string_parameter (msg, "String", NULL, category);
+ e_ews_request_write_string_parameter (request, "String", NULL, category);
}
- e_soap_request_end_element (msg); /* Categories */
+ e_soap_request_end_element (request); /* Categories */
}
g_slist_free_full (categ_list, g_free);
@@ -1154,28 +1145,28 @@ convert_vevent_calcomp_to_xml (ESoapRequest *request,
/* FORMAT OF A SAMPLE SOAP MESSAGE: http://msdn.microsoft.com/en-us/library/aa564690.aspx */
/* Prepare CalendarItem node in the SOAP message */
- e_soap_request_start_element (msg, "CalendarItem", NULL, NULL);
+ e_soap_request_start_element (request, "CalendarItem", NULL, NULL);
/* subject */
value = i_cal_component_get_summary (icomp);
if (value)
- e_ews_request_write_string_parameter (msg, "Subject", NULL, value);
+ e_ews_request_write_string_parameter (request, "Subject", NULL, value);
- convert_sensitivity_calcomp_to_xml (msg, icomp);
+ convert_sensitivity_calcomp_to_xml (request, icomp);
/* description */
value = i_cal_component_get_description (icomp);
if (value)
- e_ews_request_write_string_parameter_with_attribute (msg, "Body", NULL, value, "BodyType",
"Text");
+ e_ews_request_write_string_parameter_with_attribute (request, "Body", NULL, value,
"BodyType", "Text");
- convert_categories_calcomp_to_xml (msg, comp, icomp);
+ convert_categories_calcomp_to_xml (request, comp, icomp);
/* set alarms */
has_alarms = e_cal_component_has_alarms (comp);
if (has_alarms)
- ews_set_alarm (msg, comp, convert_data->timezone_cache, convert_data->vcalendar, FALSE);
+ ews_set_alarm (request, comp, convert_data->timezone_cache, convert_data->vcalendar, FALSE);
else
- e_ews_request_write_string_parameter (msg, "ReminderIsSet", NULL, "false");
+ e_ews_request_write_string_parameter (request, "ReminderIsSet", NULL, "false");
/* start time, end time and meeting time zone */
dtstart = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache,
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
@@ -1193,14 +1184,12 @@ convert_vevent_calcomp_to_xml (ESoapRequest *request,
satisfies = e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010);
if (satisfies && ical_location_start != NULL && ical_location_end != NULL) {
/* set iana timezone info as an extended property */
- e_ews_request_add_extended_property_distinguished_name_string (
- msg,
+ e_ews_request_add_extended_property_distinguished_name_string (request,
"PublicStrings",
"EvolutionEWSStartTimeZone",
ical_location_start);
- e_ews_request_add_extended_property_distinguished_name_string (
- msg,
+ e_ews_request_add_extended_property_distinguished_name_string (request,
"PublicStrings",
"EvolutionEWSEndTimeZone",
ical_location_end);
@@ -1208,49 +1197,49 @@ convert_vevent_calcomp_to_xml (ESoapRequest *request,
is_all_day_event = check_is_all_day_event (dtstart, tzid_start, dtend, tzid_end);
- e_ews_cal_utils_set_time (msg, "Start", dtstart, is_all_day_event && i_cal_time_is_date (dtstart));
+ e_ews_cal_utils_set_time (request, "Start", dtstart, is_all_day_event && i_cal_time_is_date
(dtstart));
/* Cover components without DTEND */
if (dtend && i_cal_time_is_valid_time (dtend) &&
!i_cal_time_is_null_time (dtend))
- e_ews_cal_utils_set_time (msg, "End", dtend, is_all_day_event && i_cal_time_is_date (dtend));
+ e_ews_cal_utils_set_time (request, "End", dtend, is_all_day_event && i_cal_time_is_date
(dtend));
else
- e_ews_cal_utils_set_time (msg, "End", dtstart, is_all_day_event && i_cal_time_is_date
(dtstart));
+ e_ews_cal_utils_set_time (request, "End", dtstart, is_all_day_event && i_cal_time_is_date
(dtstart));
/* We have to do the time zone(s) later, or the server rejects the request */
/* All day event ? */
if (is_all_day_event)
- e_ews_request_write_string_parameter (msg, "IsAllDayEvent", NULL, "true");
+ e_ews_request_write_string_parameter (request, "IsAllDayEvent", NULL, "true");
/*freebusy*/
prop = i_cal_component_get_first_property (icomp, I_CAL_TRANSP_PROPERTY);
if (!prop || i_cal_property_get_transp (prop) == I_CAL_TRANSP_TRANSPARENT)
- e_ews_request_write_string_parameter (msg, "LegacyFreeBusyStatus", NULL, "Free");
+ e_ews_request_write_string_parameter (request, "LegacyFreeBusyStatus", NULL, "Free");
else
- e_ews_request_write_string_parameter (msg, "LegacyFreeBusyStatus", NULL, "Busy");
+ e_ews_request_write_string_parameter (request, "LegacyFreeBusyStatus", NULL, "Busy");
g_clear_object (&prop);
/* location */
value = i_cal_component_get_location (icomp);
if (value)
- e_ews_request_write_string_parameter (msg, "Location", NULL, value);
+ e_ews_request_write_string_parameter (request, "Location", NULL, value);
/* collect attendees */
e_ews_collect_attendees (icomp, &required, &optional, &resource, &rsvp_requested);
- e_ews_request_write_string_parameter (msg, "IsResponseRequested", NULL, rsvp_requested ? "true" :
"false");
+ e_ews_request_write_string_parameter (request, "IsResponseRequested", NULL, rsvp_requested ? "true" :
"false");
if (required != NULL) {
- add_attendees_list_to_message (msg, "RequiredAttendees", required);
+ add_attendees_list_to_message (request, "RequiredAttendees", required);
g_slist_free (required);
}
if (optional != NULL) {
- add_attendees_list_to_message (msg, "OptionalAttendees", optional);
+ add_attendees_list_to_message (request, "OptionalAttendees", optional);
g_slist_free (optional);
}
if (resource != NULL) {
- add_attendees_list_to_message (msg, "Resources", resource);
+ add_attendees_list_to_message (request, "Resources", resource);
g_slist_free (resource);
}
/* end of attendees */
@@ -1258,7 +1247,7 @@ convert_vevent_calcomp_to_xml (ESoapRequest *request,
/* Recurrence */
prop = i_cal_component_get_first_property (icomp, I_CAL_RRULE_PROPERTY);
if (prop) {
- ewscal_set_reccurence (msg, prop, dtstart);
+ ewscal_set_reccurence (request, prop, dtstart);
g_object_unref (prop);
}
@@ -1280,19 +1269,19 @@ convert_vevent_calcomp_to_xml (ESoapRequest *request,
&tzds,
NULL,
NULL)) {
- ewscal_set_timezone (msg, "StartTimeZone", tzds->data);
- ewscal_set_timezone (msg, "EndTimeZone", tzds->data);
+ ewscal_set_timezone (request, "StartTimeZone", tzds->data);
+ ewscal_set_timezone (request, "EndTimeZone", tzds->data);
}
g_slist_free (msdn_locations);
g_slist_free_full (tzds, (GDestroyNotify) e_ews_calendar_time_zone_definition_free);
} else {
- e_ews_request_replace_server_version (msg, E_EWS_EXCHANGE_2007_SP1);
+ e_ews_request_replace_server_version (request, E_EWS_EXCHANGE_2007_SP1);
- ewscal_set_meeting_timezone (msg, tzid_start, icomp);
+ ewscal_set_meeting_timezone (request, tzid_start, icomp);
}
- e_soap_request_end_element (msg); /* "CalendarItem" */
+ e_soap_request_end_element (request); /* "CalendarItem" */
g_clear_object (&dtstart);
g_clear_object (&dtend);
@@ -1327,29 +1316,29 @@ convert_vtodo_calcomp_to_xml (ESoapRequest *request,
gboolean success;
/* gboolean has_alarms; */
- e_soap_request_start_element (msg, "Task", NULL, NULL);
+ e_soap_request_start_element (request, "Task", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "Subject", NULL, i_cal_component_get_summary (icomp));
+ e_ews_request_write_string_parameter (request, "Subject", NULL, i_cal_component_get_summary (icomp));
- convert_sensitivity_calcomp_to_xml (msg, icomp);
+ convert_sensitivity_calcomp_to_xml (request, icomp);
- e_ews_request_write_string_parameter_with_attribute (msg, "Body", NULL,
i_cal_component_get_description (icomp), "BodyType", "Text");
+ e_ews_request_write_string_parameter_with_attribute (request, "Body", NULL,
i_cal_component_get_description (icomp), "BodyType", "Text");
- convert_categories_calcomp_to_xml (msg, NULL, icomp);
+ convert_categories_calcomp_to_xml (request, NULL, icomp);
prop = i_cal_component_get_first_property (icomp, I_CAL_PRIORITY_PROPERTY);
if (prop) {
gint priority;
priority = i_cal_property_get_priority (prop);
- e_ews_request_write_string_parameter (msg, "Importance", NULL, ews_priority_to_string
(priority));
+ e_ews_request_write_string_parameter (request, "Importance", NULL, ews_priority_to_string
(priority));
g_object_unref (prop);
}
prop = i_cal_component_get_first_property (icomp, I_CAL_DUE_PROPERTY);
if (prop) {
dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache,
convert_data->vcalendar, icomp, I_CAL_DUE_PROPERTY, i_cal_property_get_due);
- e_ews_cal_utils_set_time (msg, "DueDate", dt, TRUE);
+ e_ews_cal_utils_set_time (request, "DueDate", dt, TRUE);
g_clear_object (&dt);
g_object_unref (prop);
}
@@ -1358,16 +1347,16 @@ convert_vtodo_calcomp_to_xml (ESoapRequest *request,
if (prop) {
value = i_cal_property_get_percentcomplete (prop);
snprintf (buffer, 16, "%d", value);
- e_ews_request_write_string_parameter (msg, "PercentComplete", NULL, buffer);
+ e_ews_request_write_string_parameter (request, "PercentComplete", NULL, buffer);
g_object_unref (prop);
}
- success = e_ews_cal_utils_set_recurrence (msg, icomp, FALSE, error);
+ success = e_ews_cal_utils_set_recurrence (request, icomp, FALSE, error);
prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
if (prop) {
dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache,
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
- e_ews_cal_utils_set_time (msg, "StartDate", dt, TRUE);
+ e_ews_cal_utils_set_time (request, "StartDate", dt, TRUE);
g_clear_object (&dt);
g_object_unref (prop);
}
@@ -1376,10 +1365,10 @@ convert_vtodo_calcomp_to_xml (ESoapRequest *request,
if (prop) {
switch (i_cal_property_get_status (prop)) {
case I_CAL_STATUS_INPROCESS:
- e_ews_request_write_string_parameter (msg, "Status", NULL, "InProgress");
+ e_ews_request_write_string_parameter (request, "Status", NULL, "InProgress");
break;
case I_CAL_STATUS_COMPLETED:
- e_ews_request_write_string_parameter (msg, "Status", NULL, "Completed");
+ e_ews_request_write_string_parameter (request, "Status", NULL, "Completed");
break;
default:
break;
@@ -1392,7 +1381,7 @@ convert_vtodo_calcomp_to_xml (ESoapRequest *request,
ECalComponent *comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (icomp));
if (comp && e_cal_component_has_alarms (comp)) {
- ews_set_alarm (msg, comp, convert_data->timezone_cache, convert_data->vcalendar,
TRUE);
+ ews_set_alarm (request, comp, convert_data->timezone_cache, convert_data->vcalendar,
TRUE);
} else {
has_alarms = FALSE;
}
@@ -1401,9 +1390,9 @@ convert_vtodo_calcomp_to_xml (ESoapRequest *request,
}
if (!has_alarms)
- e_ews_request_write_string_parameter (msg, "ReminderIsSet", NULL, "false"); */
+ e_ews_request_write_string_parameter (request, "ReminderIsSet", NULL, "false"); */
- e_soap_request_end_element (msg); /* "Task" */
+ e_soap_request_end_element (request); /* "Task" */
return success;
}
@@ -1417,21 +1406,21 @@ convert_vjournal_calcomp_to_xml (ESoapRequest *request,
ICalComponent *icomp = convert_data->icomp;
const gchar *text;
- e_soap_request_start_element (msg, "Message", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "ItemClass", NULL, "IPM.StickyNote");
+ e_soap_request_start_element (request, "Message", NULL, NULL);
+ e_ews_request_write_string_parameter (request, "ItemClass", NULL, "IPM.StickyNote");
- e_ews_request_write_string_parameter (msg, "Subject", NULL, i_cal_component_get_summary (icomp));
+ e_ews_request_write_string_parameter (request, "Subject", NULL, i_cal_component_get_summary (icomp));
- convert_sensitivity_calcomp_to_xml (msg, icomp);
+ convert_sensitivity_calcomp_to_xml (request, icomp);
text = i_cal_component_get_description (icomp);
if (!text || !*text)
text = i_cal_component_get_summary (icomp);
- e_ews_request_write_string_parameter_with_attribute (msg, "Body", NULL, text, "BodyType", "Text");
+ e_ews_request_write_string_parameter_with_attribute (request, "Body", NULL, text, "BodyType", "Text");
- convert_categories_calcomp_to_xml (msg, NULL, icomp);
+ convert_categories_calcomp_to_xml (request, NULL, icomp);
- e_soap_request_end_element (msg); /* Message */
+ e_soap_request_end_element (request); /* Message */
return TRUE;
}
@@ -1446,13 +1435,13 @@ e_cal_backend_ews_convert_calcomp_to_xml (ESoapRequest *request,
switch (i_cal_component_isa (convert_data->icomp)) {
case I_CAL_VEVENT_COMPONENT:
- success = convert_vevent_calcomp_to_xml (msg, convert_data, error);
+ success = convert_vevent_calcomp_to_xml (request, convert_data, error);
break;
case I_CAL_VTODO_COMPONENT:
- success = convert_vtodo_calcomp_to_xml (msg, convert_data, error);
+ success = convert_vtodo_calcomp_to_xml (request, convert_data, error);
break;
case I_CAL_VJOURNAL_COMPONENT:
- success = convert_vjournal_calcomp_to_xml (msg, convert_data, error);
+ success = convert_vjournal_calcomp_to_xml (request, convert_data, error);
break;
default:
g_warn_if_reached ();
@@ -1470,13 +1459,13 @@ convert_component_categories_to_updatexml (ECalComponent *comp,
GSList *categ_list, *citer;
g_return_if_fail (comp != NULL);
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (base_elem_name != NULL);
categ_list = e_cal_component_get_categories_list (comp);
- e_ews_request_start_set_item_field (msg, "Categories", "item", base_elem_name);
- e_soap_request_start_element (msg, "Categories", NULL, NULL);
+ e_ews_request_start_set_item_field (request, "Categories", "item", base_elem_name);
+ e_soap_request_start_element (request, "Categories", NULL, NULL);
for (citer = categ_list; citer; citer = g_slist_next (citer)) {
const gchar *category = citer->data;
@@ -1484,11 +1473,11 @@ convert_component_categories_to_updatexml (ECalComponent *comp,
if (!category || !*category)
continue;
- e_ews_request_write_string_parameter (msg, "String", NULL, category);
+ e_ews_request_write_string_parameter (request, "String", NULL, category);
}
- e_soap_request_end_element (msg); /* Categories */
- e_ews_request_end_set_item_field (msg);
+ e_soap_request_end_element (request); /* Categories */
+ e_ews_request_end_set_item_field (request);
g_slist_free_full (categ_list, g_free);
}
@@ -1501,9 +1490,9 @@ convert_vevent_property_to_updatexml (ESoapRequest *request,
const gchar *attr_name,
const gchar *attr_value)
{
- e_ews_request_start_set_item_field (msg, name, prefix, "CalendarItem");
- e_ews_request_write_string_parameter_with_attribute (msg, name, NULL, value, attr_name, attr_value);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, name, prefix, "CalendarItem");
+ e_ews_request_write_string_parameter_with_attribute (request, name, NULL, value, attr_name,
attr_value);
+ e_ews_request_end_set_item_field (request);
}
static gboolean
@@ -1530,14 +1519,13 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
gboolean satisfies, rsvp_requested = TRUE, is_all_day_event = FALSE;
if (convert_data->change_type == E_EWS_ITEMCHANGE_TYPE_OCCURRENCEITEM && convert_data->index > 0) {
- e_ews_request_start_item_change (
- msg,
+ e_ews_request_start_item_change (request,
convert_data->change_type,
convert_data->item_id,
convert_data->change_key,
convert_data->index);
} else {
- e_ews_request_start_item_change (msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+ e_ews_request_start_item_change (request, E_EWS_ITEMCHANGE_TYPE_ITEM,
convert_data->item_id, convert_data->change_key, 0);
}
@@ -1545,20 +1533,20 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
value = i_cal_component_get_summary (icomp);
old_value = i_cal_component_get_summary (icomp_old);
if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
- convert_vevent_property_to_updatexml (msg, "Subject", value, "item", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "Subject", value, "item", NULL, NULL);
} else if (!value && old_value) {
- convert_vevent_property_to_updatexml (msg, "Subject", "", "item", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "Subject", "", "item", NULL, NULL);
}
prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
if (prop) {
ICalProperty_Class classify = i_cal_property_get_class (prop);
if (classify == I_CAL_CLASS_PUBLIC) {
- convert_vevent_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL,
NULL);
+ convert_vevent_property_to_updatexml (request, "Sensitivity", "Normal", "item", NULL,
NULL);
} else if (classify == I_CAL_CLASS_PRIVATE) {
- convert_vevent_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL,
NULL);
+ convert_vevent_property_to_updatexml (request, "Sensitivity", "Private", "item",
NULL, NULL);
} else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
- convert_vevent_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL,
NULL);
+ convert_vevent_property_to_updatexml (request, "Sensitivity", "Personal", "item",
NULL, NULL);
}
g_object_unref (prop);
@@ -1568,9 +1556,9 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
value = i_cal_component_get_description (icomp);
old_value = i_cal_component_get_description (icomp_old);
if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
- convert_vevent_property_to_updatexml (msg, "Body", value, "item", "BodyType", "Text");
+ convert_vevent_property_to_updatexml (request, "Body", value, "item", "BodyType", "Text");
} else if (!value && old_value) {
- convert_vevent_property_to_updatexml (msg, "Body", "", "item", "BodyType", "Text");
+ convert_vevent_property_to_updatexml (request, "Body", "", "item", "BodyType", "Text");
}
/*update alarm items*/
@@ -1585,23 +1573,23 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
if (alarm != alarm_old || !has_alarms_old) {
gchar buf[20];
snprintf (buf, 20, "%d", alarm);
- convert_vevent_property_to_updatexml (msg, "ReminderIsSet", "true", "item", NULL,
NULL);
- convert_vevent_property_to_updatexml (msg, "ReminderMinutesBeforeStart", buf, "item",
NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "ReminderIsSet", "true", "item", NULL,
NULL);
+ convert_vevent_property_to_updatexml (request, "ReminderMinutesBeforeStart", buf,
"item", NULL, NULL);
}
} else {
- convert_vevent_property_to_updatexml (msg, "ReminderIsSet", "false", "item", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "ReminderIsSet", "false", "item", NULL, NULL);
}
/* Categories */
- convert_component_categories_to_updatexml (convert_data->comp, msg, "CalendarItem");
+ convert_component_categories_to_updatexml (convert_data->comp, request, "CalendarItem");
/*location*/
value = i_cal_component_get_location (icomp);
old_value = i_cal_component_get_location (icomp_old);
if (g_strcmp0 (value, old_value) != 0 || (value && !old_value)) {
- convert_vevent_property_to_updatexml (msg, "Location", value, "calendar", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "Location", value, "calendar", NULL, NULL);
} else if (!value && old_value) {
- convert_vevent_property_to_updatexml (msg, "Location", "", "calendar", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "Location", "", "calendar", NULL, NULL);
}
/*freebusy*/
@@ -1613,14 +1601,14 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
g_clear_object (&prop);
if (new_transp != old_transp) {
if (new_transp == I_CAL_TRANSP_TRANSPARENT)
- convert_vevent_property_to_updatexml (msg, "LegacyFreeBusyStatus","Free" ,
"calendar", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "LegacyFreeBusyStatus","Free" ,
"calendar", NULL, NULL);
else
- convert_vevent_property_to_updatexml (msg, "LegacyFreeBusyStatus","Busy" ,
"calendar", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "LegacyFreeBusyStatus","Busy" ,
"calendar", NULL, NULL);
}
org_email_address = e_ews_collect_organizer (icomp);
if (org_email_address && convert_data->user_email && g_ascii_strcasecmp (org_email_address,
convert_data->user_email)) {
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
return TRUE;
}
@@ -1682,8 +1670,7 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
dt_end_changed = TRUE;
if ((dt_start_changed || dt_start_changed_timezone_name) && ical_location_start != NULL)
- e_ews_request_add_set_item_field_extended_distinguished_name_string (
- msg,
+ e_ews_request_add_set_item_field_extended_distinguished_name_string (request,
NULL,
"CalendarItem",
"PublicStrings",
@@ -1691,8 +1678,7 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
ical_location_start);
if ((dt_end_changed || dt_end_changed_timezone_name) && ical_location_end != NULL)
- e_ews_request_add_set_item_field_extended_distinguished_name_string (
- msg,
+ e_ews_request_add_set_item_field_extended_distinguished_name_string (request,
NULL,
"CalendarItem",
"PublicStrings",
@@ -1706,52 +1692,52 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
is_all_day_event = check_is_all_day_event (dtstart, tzid_start, dtend, tzid_end);
if (dt_start_changed) {
- e_ews_request_start_set_item_field (msg, "Start", "calendar","CalendarItem");
- e_ews_cal_utils_set_time (msg, "Start", dtstart, is_all_day_event && i_cal_time_is_date
(dtstart));
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "Start", "calendar","CalendarItem");
+ e_ews_cal_utils_set_time (request, "Start", dtstart, is_all_day_event && i_cal_time_is_date
(dtstart));
+ e_ews_request_end_set_item_field (request);
}
if (dt_end_changed) {
- e_ews_request_start_set_item_field (msg, "End", "calendar", "CalendarItem");
- e_ews_cal_utils_set_time (msg, "End", dtend, is_all_day_event && i_cal_time_is_date (dtend));
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "End", "calendar", "CalendarItem");
+ e_ews_cal_utils_set_time (request, "End", dtend, is_all_day_event && i_cal_time_is_date
(dtend));
+ e_ews_request_end_set_item_field (request);
}
/*Check for All Day Event*/
if (dt_changed) {
if (is_all_day_event)
- convert_vevent_property_to_updatexml (msg, "IsAllDayEvent", "true", "calendar", NULL,
NULL);
+ convert_vevent_property_to_updatexml (request, "IsAllDayEvent", "true", "calendar",
NULL, NULL);
else
- convert_vevent_property_to_updatexml (msg, "IsAllDayEvent", "false", "calendar",
NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "IsAllDayEvent", "false", "calendar",
NULL, NULL);
}
e_ews_collect_attendees (icomp, &required, &optional, &resource, &rsvp_requested);
- convert_vevent_property_to_updatexml (msg, "IsResponseRequested", rsvp_requested ? "true" : "false",
"calendar", NULL, NULL);
+ convert_vevent_property_to_updatexml (request, "IsResponseRequested", rsvp_requested ? "true" :
"false", "calendar", NULL, NULL);
if (required != NULL) {
- e_ews_request_start_set_item_field (msg, "RequiredAttendees", "calendar", "CalendarItem");
+ e_ews_request_start_set_item_field (request, "RequiredAttendees", "calendar", "CalendarItem");
- add_attendees_list_to_message (msg, "RequiredAttendees", required);
+ add_attendees_list_to_message (request, "RequiredAttendees", required);
g_slist_free (required);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_end_set_item_field (request);
}
if (optional != NULL) {
- e_ews_request_start_set_item_field (msg, "OptionalAttendees", "calendar", "CalendarItem");
+ e_ews_request_start_set_item_field (request, "OptionalAttendees", "calendar", "CalendarItem");
- add_attendees_list_to_message (msg, "OptionalAttendees", optional);
+ add_attendees_list_to_message (request, "OptionalAttendees", optional);
g_slist_free (optional);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_end_set_item_field (request);
}
if (resource != NULL) {
- e_ews_request_start_set_item_field (msg, "Resources", "calendar", "CalendarItem");
+ e_ews_request_start_set_item_field (request, "Resources", "calendar", "CalendarItem");
- add_attendees_list_to_message (msg, "Resources", resource);
+ add_attendees_list_to_message (request, "Resources", resource);
g_slist_free (resource);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_end_set_item_field (request);
}
/* Recurrence */
@@ -1768,9 +1754,9 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
rrule_value = i_cal_property_get_value_as_string (prop);
if (prop && g_strcmp0 (rrule_value, rrule_old_value)) {
- e_ews_request_start_set_item_field (msg, "Recurrence", "calendar", "CalendarItem");
- ewscal_set_reccurence (msg, prop, dtstart);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "Recurrence", "calendar", "CalendarItem");
+ ewscal_set_reccurence (request, prop, dtstart);
+ e_ews_request_end_set_item_field (request);
}
g_clear_object (&prop);
g_free (rrule_value);
@@ -1798,9 +1784,9 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
tmp = tzds;
if (tzid_start != NULL) {
- e_ews_request_start_set_item_field (msg, "StartTimeZone", "calendar",
"CalendarItem");
- ewscal_set_timezone (msg, "StartTimeZone", tmp->data);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "StartTimeZone",
"calendar", "CalendarItem");
+ ewscal_set_timezone (request, "StartTimeZone", tmp->data);
+ e_ews_request_end_set_item_field (request);
/*
* Exchange server is smart enough to return the list of
@@ -1811,9 +1797,9 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
}
if (tzid_end != NULL) {
- e_ews_request_start_set_item_field (msg, "EndTimeZone", "calendar",
"CalendarItem");
- ewscal_set_timezone (msg, "EndTimeZone", tmp->data);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "EndTimeZone",
"calendar", "CalendarItem");
+ ewscal_set_timezone (request, "EndTimeZone", tmp->data);
+ e_ews_request_end_set_item_field (request);
}
}
@@ -1821,14 +1807,14 @@ convert_vevent_component_to_updatexml (ESoapRequest *request,
g_slist_free_full (tzds, (GDestroyNotify) e_ews_calendar_time_zone_definition_free);
}
} else if (dt_changed) {
- e_ews_request_replace_server_version (msg, E_EWS_EXCHANGE_2007_SP1);
+ e_ews_request_replace_server_version (request, E_EWS_EXCHANGE_2007_SP1);
- e_ews_request_start_set_item_field (msg, "MeetingTimeZone", "calendar", "CalendarItem");
- ewscal_set_meeting_timezone (msg, tzid_start ? tzid_start : convert_data->default_zone,
icomp);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "MeetingTimeZone", "calendar", "CalendarItem");
+ ewscal_set_meeting_timezone (request, tzid_start ? tzid_start : convert_data->default_zone,
icomp);
+ e_ews_request_end_set_item_field (request);
}
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
g_clear_object (&dtstart);
g_clear_object (&dtend);
@@ -1846,9 +1832,9 @@ convert_vtodo_property_to_updatexml (ESoapRequest *request,
const gchar *attr_name,
const gchar *attr_value)
{
- e_ews_request_start_set_item_field (msg, name, prefix, "Task");
- e_ews_request_write_string_parameter_with_attribute (msg, name, NULL, value, attr_name, attr_value);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, name, prefix, "Task");
+ e_ews_request_write_string_parameter_with_attribute (request, name, NULL, value, attr_name,
attr_value);
+ e_ews_request_end_set_item_field (request);
}
static gboolean
@@ -1864,46 +1850,45 @@ convert_vtodo_component_to_updatexml (ESoapRequest *request,
gchar buffer[16];
gboolean success = TRUE;
- e_ews_request_start_item_change (
- msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+ e_ews_request_start_item_change (request, E_EWS_ITEMCHANGE_TYPE_ITEM,
convert_data->item_id, convert_data->change_key, 0);
- convert_vtodo_property_to_updatexml (msg, "Subject", i_cal_component_get_summary (icomp), "item",
NULL, NULL);
+ convert_vtodo_property_to_updatexml (request, "Subject", i_cal_component_get_summary (icomp), "item",
NULL, NULL);
prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
if (prop) {
ICalProperty_Class classify = i_cal_property_get_class (prop);
if (classify == I_CAL_CLASS_PUBLIC) {
- convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL,
NULL);
+ convert_vtodo_property_to_updatexml (request, "Sensitivity", "Normal", "item", NULL,
NULL);
} else if (classify == I_CAL_CLASS_PRIVATE) {
- convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL,
NULL);
+ convert_vtodo_property_to_updatexml (request, "Sensitivity", "Private", "item", NULL,
NULL);
} else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
- convert_vtodo_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL,
NULL);
+ convert_vtodo_property_to_updatexml (request, "Sensitivity", "Personal", "item",
NULL, NULL);
}
g_object_unref (prop);
}
- convert_vtodo_property_to_updatexml (msg, "Body", i_cal_component_get_description (icomp), "item",
"BodyType", "Text");
+ convert_vtodo_property_to_updatexml (request, "Body", i_cal_component_get_description (icomp),
"item", "BodyType", "Text");
prop = i_cal_component_get_first_property (icomp, I_CAL_DUE_PROPERTY);
if (prop) {
dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache,
convert_data->vcalendar, icomp, I_CAL_DUE_PROPERTY, i_cal_property_get_due);
- e_ews_request_start_set_item_field (msg, "DueDate", "task", "Task");
- e_ews_cal_utils_set_time (msg, "DueDate", dt, TRUE);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "DueDate", "task", "Task");
+ e_ews_cal_utils_set_time (request, "DueDate", dt, TRUE);
+ e_ews_request_end_set_item_field (request);
g_object_unref (prop);
g_clear_object (&dt);
} else {
- e_ews_request_add_delete_item_field (msg, "DueDate", "task");
+ e_ews_request_add_delete_item_field (request, "DueDate", "task");
}
prop = i_cal_component_get_first_property (icomp, I_CAL_PERCENTCOMPLETE_PROPERTY);
if (prop) {
value = i_cal_property_get_percentcomplete (prop);
snprintf (buffer, 16, "%d", value);
- e_ews_request_start_set_item_field (msg, "PercentComplete", "task", "Task");
- e_ews_request_write_string_parameter (msg, "PercentComplete", NULL, buffer);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "PercentComplete", "task", "Task");
+ e_ews_request_write_string_parameter (request, "PercentComplete", NULL, buffer);
+ e_ews_request_end_set_item_field (request);
g_object_unref (prop);
}
@@ -1911,37 +1896,37 @@ convert_vtodo_component_to_updatexml (ESoapRequest *request,
value = i_cal_component_count_properties (e_cal_component_get_icalcomponent (convert_data->old_comp),
I_CAL_RRULE_PROPERTY);
if (i_cal_component_count_properties (icomp, I_CAL_RRULE_PROPERTY) > 0 ||
(e_cal_util_component_has_x_property (icomp, X_EWS_TASK_REGENERATION) && value <= 0)) {
- e_ews_request_start_set_item_field (msg, "Recurrence", "task", "Task");
- success = success && e_ews_cal_utils_set_recurrence (msg, icomp, FALSE, error);
- e_ews_request_end_set_item_field (msg); /* Recurrence */
+ e_ews_request_start_set_item_field (request, "Recurrence", "task", "Task");
+ success = success && e_ews_cal_utils_set_recurrence (request, icomp, FALSE, error);
+ e_ews_request_end_set_item_field (request); /* Recurrence */
} else if (value > 0) {
- e_ews_request_add_delete_item_field (msg, "Recurrence", "task");
+ e_ews_request_add_delete_item_field (request, "Recurrence", "task");
}
prop = i_cal_component_get_first_property (icomp, I_CAL_DTSTART_PROPERTY);
if (prop) {
dt = e_cal_backend_ews_get_datetime_with_zone (convert_data->timezone_cache,
convert_data->vcalendar, icomp, I_CAL_DTSTART_PROPERTY, i_cal_property_get_dtstart);
- e_ews_request_start_set_item_field (msg, "StartDate", "task", "Task");
- e_ews_cal_utils_set_time (msg, "StartDate", dt, TRUE);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, "StartDate", "task", "Task");
+ e_ews_cal_utils_set_time (request, "StartDate", dt, TRUE);
+ e_ews_request_end_set_item_field (request);
g_object_unref (prop);
g_clear_object (&dt);
} else {
- e_ews_request_add_delete_item_field (msg, "StartDate", "task");
+ e_ews_request_add_delete_item_field (request, "StartDate", "task");
}
prop = i_cal_component_get_first_property (icomp, I_CAL_STATUS_PROPERTY);
if (prop) {
switch (i_cal_property_get_status (prop)) {
case I_CAL_STATUS_INPROCESS:
- convert_vtodo_property_to_updatexml (msg, "Status", "InProgress", "task", NULL, NULL);
+ convert_vtodo_property_to_updatexml (request, "Status", "InProgress", "task", NULL,
NULL);
break;
case I_CAL_STATUS_COMPLETED:
- convert_vtodo_property_to_updatexml (msg, "Status", "Completed", "task", NULL, NULL);
+ convert_vtodo_property_to_updatexml (request, "Status", "Completed", "task", NULL,
NULL);
break;
case I_CAL_STATUS_NONE:
case I_CAL_STATUS_NEEDSACTION:
- convert_vtodo_property_to_updatexml (msg, "Status", "NotStarted", "task", NULL, NULL);
+ convert_vtodo_property_to_updatexml (request, "Status", "NotStarted", "task", NULL,
NULL);
break;
default:
break;
@@ -1950,18 +1935,18 @@ convert_vtodo_component_to_updatexml (ESoapRequest *request,
}
/* Categories */
- convert_component_categories_to_updatexml (convert_data->comp, msg, "Task");
+ convert_component_categories_to_updatexml (convert_data->comp, request, "Task");
prop = i_cal_component_get_first_property (icomp, I_CAL_PRIORITY_PROPERTY);
if (prop) {
gint priority;
priority = i_cal_property_get_priority (prop);
- convert_vtodo_property_to_updatexml (msg, "Importance", ews_priority_to_string (priority),
"item", NULL, NULL);
+ convert_vtodo_property_to_updatexml (request, "Importance", ews_priority_to_string
(priority), "item", NULL, NULL);
g_object_unref (prop);
}
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
return success;
}
@@ -1974,9 +1959,9 @@ convert_vjournal_property_to_updatexml (ESoapRequest *request,
const gchar *attr_name,
const gchar *attr_value)
{
- e_ews_request_start_set_item_field (msg, name, prefix, "Message");
- e_ews_request_write_string_parameter_with_attribute (msg, name, NULL, value, attr_name, attr_value);
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_start_set_item_field (request, name, prefix, "Message");
+ e_ews_request_write_string_parameter_with_attribute (request, name, NULL, value, attr_name,
attr_value);
+ e_ews_request_end_set_item_field (request);
}
static gboolean
@@ -1989,22 +1974,21 @@ convert_vjournal_component_to_updatexml (ESoapRequest *request,
ICalProperty *prop;
const gchar *text;
- e_ews_request_start_item_change (
- msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+ e_ews_request_start_item_change (request, E_EWS_ITEMCHANGE_TYPE_ITEM,
convert_data->item_id, convert_data->change_key, 0);
- convert_vjournal_property_to_updatexml (msg, "ItemClass", "IPM.StickyNote", "item", NULL, NULL);
- convert_vjournal_property_to_updatexml (msg, "Subject", i_cal_component_get_summary (icomp), "item",
NULL, NULL);
+ convert_vjournal_property_to_updatexml (request, "ItemClass", "IPM.StickyNote", "item", NULL, NULL);
+ convert_vjournal_property_to_updatexml (request, "Subject", i_cal_component_get_summary (icomp),
"item", NULL, NULL);
prop = i_cal_component_get_first_property (icomp, I_CAL_CLASS_PROPERTY);
if (prop) {
ICalProperty_Class classify = i_cal_property_get_class (prop);
if (classify == I_CAL_CLASS_PUBLIC) {
- convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Normal", "item", NULL,
NULL);
+ convert_vjournal_property_to_updatexml (request, "Sensitivity", "Normal", "item",
NULL, NULL);
} else if (classify == I_CAL_CLASS_PRIVATE) {
- convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Private", "item", NULL,
NULL);
+ convert_vjournal_property_to_updatexml (request, "Sensitivity", "Private", "item",
NULL, NULL);
} else if (classify == I_CAL_CLASS_CONFIDENTIAL) {
- convert_vjournal_property_to_updatexml (msg, "Sensitivity", "Personal", "item", NULL,
NULL);
+ convert_vjournal_property_to_updatexml (request, "Sensitivity", "Personal", "item",
NULL, NULL);
}
g_object_unref (prop);
}
@@ -2013,12 +1997,12 @@ convert_vjournal_component_to_updatexml (ESoapRequest *request,
if (!text || !*text)
text = i_cal_component_get_summary (icomp);
- convert_vjournal_property_to_updatexml (msg, "Body", text, "item", "BodyType", "Text");
+ convert_vjournal_property_to_updatexml (request, "Body", text, "item", "BodyType", "Text");
/* Categories */
- convert_component_categories_to_updatexml (convert_data->comp, msg, "Message");
+ convert_component_categories_to_updatexml (convert_data->comp, request, "Message");
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
return TRUE;
}
@@ -2034,13 +2018,13 @@ e_cal_backend_ews_convert_component_to_updatexml (ESoapRequest *request,
switch (i_cal_component_isa (icomp)) {
case I_CAL_VEVENT_COMPONENT:
- success = convert_vevent_component_to_updatexml (msg, user_data, error);
+ success = convert_vevent_component_to_updatexml (request, user_data, error);
break;
case I_CAL_VTODO_COMPONENT:
- success = convert_vtodo_component_to_updatexml (msg, user_data, error);
+ success = convert_vtodo_component_to_updatexml (request, user_data, error);
break;
case I_CAL_VJOURNAL_COMPONENT:
- success = convert_vjournal_component_to_updatexml (msg, user_data, error);
+ success = convert_vjournal_component_to_updatexml (request, user_data, error);
break;
default:
break;
@@ -2120,20 +2104,19 @@ e_cal_backend_ews_clear_reminder_is_set (ESoapRequest *request,
{
EwsCalendarConvertData *convert_data = user_data;
- e_ews_request_start_item_change (
- msg,
+ e_ews_request_start_item_change (request,
convert_data->change_type,
convert_data->item_id,
convert_data->change_key,
convert_data->index);
- e_ews_request_start_set_item_field (msg, "ReminderIsSet","item", "CalendarItem");
+ e_ews_request_start_set_item_field (request, "ReminderIsSet","item", "CalendarItem");
- e_ews_request_write_string_parameter (msg, "ReminderIsSet", NULL, "false");
+ e_ews_request_write_string_parameter (request, "ReminderIsSet", NULL, "false");
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_end_set_item_field (request);
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
return TRUE;
}
@@ -2145,15 +2128,15 @@ e_cal_backend_ews_prepare_set_free_busy_status (ESoapRequest *request,
{
EwsCalendarConvertData *data = user_data;
- e_ews_request_start_item_change (msg, E_EWS_ITEMCHANGE_TYPE_ITEM, data->item_id, data->change_key, 0);
+ e_ews_request_start_item_change (request, E_EWS_ITEMCHANGE_TYPE_ITEM, data->item_id,
data->change_key, 0);
- e_ews_request_start_set_item_field (msg, "LegacyFreeBusyStatus", "calendar", "CalendarItem");
+ e_ews_request_start_set_item_field (request, "LegacyFreeBusyStatus", "calendar", "CalendarItem");
- e_ews_request_write_string_parameter (msg, "LegacyFreeBusyStatus", NULL, "Free");
+ e_ews_request_write_string_parameter (request, "LegacyFreeBusyStatus", NULL, "Free");
- e_ews_request_end_set_item_field (msg);
+ e_ews_request_end_set_item_field (request);
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
return TRUE;
}
@@ -2173,19 +2156,19 @@ e_cal_backend_ews_prepare_accept_item_request (ESoapRequest *request,
* Prepare AcceptItem node in the SOAP message */
if (response_type && !g_ascii_strcasecmp (response_type, "ACCEPTED"))
- e_soap_request_start_element (msg, "AcceptItem", NULL, NULL);
+ e_soap_request_start_element (request, "AcceptItem", NULL, NULL);
else if (response_type && !g_ascii_strcasecmp (response_type, "DECLINED"))
- e_soap_request_start_element (msg, "DeclineItem", NULL, NULL);
+ e_soap_request_start_element (request, "DeclineItem", NULL, NULL);
else
- e_soap_request_start_element (msg, "TentativelyAcceptItem", NULL, NULL);
+ e_soap_request_start_element (request, "TentativelyAcceptItem", NULL, NULL);
- e_soap_request_start_element (msg, "ReferenceItemId", NULL, NULL);
- e_soap_request_add_attribute (msg, "Id", data->item_id, NULL, NULL);
- e_soap_request_add_attribute (msg, "ChangeKey", data->change_key, NULL, NULL);
- e_soap_request_end_element (msg); /* "ReferenceItemId" */
+ e_soap_request_start_element (request, "ReferenceItemId", NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", data->item_id, NULL, NULL);
+ e_soap_request_add_attribute (request, "ChangeKey", data->change_key, NULL, NULL);
+ e_soap_request_end_element (request); /* "ReferenceItemId" */
/* end of "AcceptItem" */
- e_soap_request_end_element (msg);
+ e_soap_request_end_element (request);
return TRUE;
}
diff --git a/src/EWS/camel/camel-ews-folder.c b/src/EWS/camel/camel-ews-folder.c
index 66087cf3..087f2625 100644
--- a/src/EWS/camel/camel-ews-folder.c
+++ b/src/EWS/camel/camel-ews-folder.c
@@ -345,7 +345,7 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
gint fd_old;
gchar *mime_fname_new = NULL;
- // original mime file
+ /* original mime file */
fd_old = open (mime_fname, O_RDONLY);
if (fd_old == -1) {
g_set_error (
@@ -485,7 +485,7 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar *mime_fname,
g_object_unref (mimeparser);
close (fd_old);
- // must be freed in the caller
+ /* must be freed in the caller */
return mime_fname_new;
}
@@ -792,7 +792,7 @@ camel_ews_folder_get_message (CamelFolder *folder,
cnc, pri, ids, "IdOnly", add_props,
TRUE, mime_dir, E_EWS_BODY_TYPE_ANY,
&items,
- (ESoapProgressFn) camel_operation_progress,
+ (ESoapResponseProgressFn) camel_operation_progress,
(gpointer) cancellable,
cancellable, &local_error);
e_ews_additional_props_free (add_props);
@@ -858,7 +858,7 @@ camel_ews_folder_get_message (CamelFolder *folder,
cnc, pri, ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY,
&items_req,
- (ESoapProgressFn) camel_operation_progress,
+ (ESoapResponseProgressFn) camel_operation_progress,
(gpointer) cancellable,
cancellable, &local_error);
@@ -894,7 +894,7 @@ camel_ews_folder_get_message (CamelFolder *folder,
cnc, pri, html_body_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_BEST,
&html_body_resp,
- (ESoapProgressFn) camel_operation_progress,
+ (ESoapResponseProgressFn) 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;
@@ -1292,7 +1292,7 @@ msg_update_flags (ESoapRequest *request,
flags_changed = camel_ews_message_info_get_server_flags (emi) ^ mi_flags;
e_ews_request_start_item_change (
- msg, E_EWS_ITEMCHANGE_TYPE_ITEM,
+ request, E_EWS_ITEMCHANGE_TYPE_ITEM,
camel_message_info_get_uid (mi), camel_ews_message_info_get_change_key (emi), 0);
if (flags_changed & CAMEL_MESSAGE_FLAGGED) {
const gchar *flag;
@@ -1302,33 +1302,33 @@ msg_update_flags (ESoapRequest *request,
else
flag = "Normal";
- e_soap_request_start_element (msg, "SetItemField", NULL, NULL);
+ e_soap_request_start_element (request, "SetItemField", NULL, NULL);
- e_soap_request_start_element (msg, "FieldURI", NULL, NULL);
- e_soap_request_add_attribute (msg, "FieldURI", "item:Importance", NULL, NULL);
- e_soap_request_end_element (msg);
+ e_soap_request_start_element (request, "FieldURI", NULL, NULL);
+ e_soap_request_add_attribute (request, "FieldURI", "item:Importance", NULL, NULL);
+ e_soap_request_end_element (request);
- e_soap_request_start_element (msg, "Message", NULL, NULL);
+ e_soap_request_start_element (request, "Message", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "Importance", NULL, flag);
+ e_ews_request_write_string_parameter (request, "Importance", NULL, flag);
- e_soap_request_end_element (msg); /* Message */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* Message */
+ e_soap_request_end_element (request); /* SetItemField */
}
if (flags_changed & CAMEL_MESSAGE_SEEN) {
- e_soap_request_start_element (msg, "SetItemField", NULL, NULL);
+ e_soap_request_start_element (request, "SetItemField", NULL, NULL);
- e_soap_request_start_element (msg, "FieldURI", NULL, NULL);
- e_soap_request_add_attribute (msg, "FieldURI", "message:IsRead", NULL, NULL);
- e_soap_request_end_element (msg);
+ e_soap_request_start_element (request, "FieldURI", NULL, NULL);
+ e_soap_request_add_attribute (request, "FieldURI", "message:IsRead", NULL, NULL);
+ e_soap_request_end_element (request);
- e_soap_request_start_element (msg, "Message", NULL, NULL);
- e_ews_request_write_string_parameter (msg, "IsRead", NULL,
+ e_soap_request_start_element (request, "Message", NULL, NULL);
+ e_ews_request_write_string_parameter (request, "IsRead", NULL,
(mi_flags & CAMEL_MESSAGE_SEEN) ? "true" : "false");
- e_soap_request_end_element (msg); /* Message */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* Message */
+ e_soap_request_end_element (request); /* SetItemField */
}
/* Ick Ick Ick. Why in hell is there a field in the database for the Icon
* *anyway*? Why isn't there a better place for forwarded/answered status? */
@@ -1340,41 +1340,41 @@ msg_update_flags (ESoapRequest *request,
if (mi_flags & CAMEL_MESSAGE_FORWARDED)
icon = 0x106;
- e_ews_request_add_set_item_field_extended_tag_int (msg, NULL, "Message", 0x1080,
icon);
+ e_ews_request_add_set_item_field_extended_tag_int (request, NULL, "Message", 0x1080,
icon);
}
/* now update the Categories */
- user_flags = ews_utils_gather_server_user_flags (msg, mi);
+ user_flags = ews_utils_gather_server_user_flags (request, mi);
if (user_flags) {
GSList *link;
- e_soap_request_start_element (msg, "SetItemField", NULL, NULL);
+ e_soap_request_start_element (request, "SetItemField", NULL, NULL);
- e_soap_request_start_element (msg, "FieldURI", NULL, NULL);
- e_soap_request_add_attribute (msg, "FieldURI", "item:Categories", NULL, NULL);
- e_soap_request_end_element (msg);
+ e_soap_request_start_element (request, "FieldURI", NULL, NULL);
+ e_soap_request_add_attribute (request, "FieldURI", "item:Categories", NULL, NULL);
+ e_soap_request_end_element (request);
- e_soap_request_start_element (msg, "Message", NULL, NULL);
- e_soap_request_start_element (msg, "Categories", NULL, NULL);
+ e_soap_request_start_element (request, "Message", NULL, NULL);
+ e_soap_request_start_element (request, "Categories", NULL, NULL);
for (link = user_flags; link; link = g_slist_next (link)) {
const gchar *user_flag = link->data;
- e_ews_request_write_string_parameter (msg, "String", NULL, user_flag);
+ e_ews_request_write_string_parameter (request, "String", NULL, user_flag);
}
- e_soap_request_end_element (msg); /* Categories */
- e_soap_request_end_element (msg); /* Message */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* Categories */
+ e_soap_request_end_element (request); /* Message */
+ e_soap_request_end_element (request); /* SetItemField */
} else {
- e_ews_request_add_delete_item_field (msg, "Categories", "item");
+ e_ews_request_add_delete_item_field (request, "Categories", "item");
}
g_slist_free_full (user_flags, g_free);
- ews_utils_update_followup_flags (msg, mi);
+ ews_utils_update_followup_flags (request, mi);
- e_ews_request_end_item_change (msg);
+ e_ews_request_end_item_change (request);
camel_message_info_set_folder_flagged (mi, FALSE);
@@ -1411,12 +1411,12 @@ ews_suppress_read_receipt (ESoapRequest *request,
/* There was requested a read-receipt, but it is handled by evolution-ews,
thus prevent an automatic send of it by the server */
- e_soap_request_start_element (msg, "SuppressReadReceipt", NULL, NULL);
- e_soap_request_start_element (msg, "ReferenceItemId", NULL, NULL);
- e_soap_request_add_attribute (msg, "Id", camel_message_info_get_uid (mi), NULL, NULL);
- e_soap_request_add_attribute (msg, "ChangeKey", camel_ews_message_info_get_change_key
(CAMEL_EWS_MESSAGE_INFO (mi)), NULL, NULL);
- e_soap_request_end_element (msg); /* "ReferenceItemId" */
- e_soap_request_end_element (msg); /* SuppressReadReceipt */
+ e_soap_request_start_element (request, "SuppressReadReceipt", NULL, NULL);
+ e_soap_request_start_element (request, "ReferenceItemId", NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", camel_message_info_get_uid (mi), NULL, NULL);
+ e_soap_request_add_attribute (request, "ChangeKey", camel_ews_message_info_get_change_key
(CAMEL_EWS_MESSAGE_INFO (mi)), NULL, NULL);
+ e_soap_request_end_element (request); /* "ReferenceItemId" */
+ e_soap_request_end_element (request); /* SuppressReadReceipt */
camel_message_info_set_flags (mi, CAMEL_EWS_MESSAGE_MSGFLAG_RN_PENDING, 0);
diff --git a/src/EWS/camel/camel-ews-store.c b/src/EWS/camel/camel-ews-store.c
index 24c1b623..80b7f5a7 100644
--- a/src/EWS/camel/camel-ews-store.c
+++ b/src/EWS/camel/camel-ews-store.c
@@ -2218,7 +2218,7 @@ ews_authenticate_sync (CamelService *service,
g_slist_free_full (created_folder_ids, g_free);
- if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) &&
+ if (g_error_matches (local_error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE) &&
e_ews_connection_get_ssl_error_details (connection, &certificate_pem, &certificate_errors)) {
source = e_ews_connection_get_source (connection);
diff --git a/src/EWS/camel/camel-ews-utils.c b/src/EWS/camel/camel-ews-utils.c
index eefd56d1..9389aba1 100644
--- a/src/EWS/camel/camel-ews-utils.c
+++ b/src/EWS/camel/camel-ews-utils.c
@@ -1297,7 +1297,7 @@ ews_utils_update_followup_flags (ESoapRequest *request,
const gchar *followup, *completed, *dueby;
time_t completed_tt = (time_t) 0 , dueby_tt = (time_t) 0;
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (mi != NULL);
followup = camel_message_info_get_user_tag (mi, "follow-up");
diff --git a/src/EWS/common/CMakeLists.txt b/src/EWS/common/CMakeLists.txt
index 40fc3880..ecc2b418 100644
--- a/src/EWS/common/CMakeLists.txt
+++ b/src/EWS/common/CMakeLists.txt
@@ -30,8 +30,6 @@ set(SOURCES
e-ews-request.h
e-oauth2-service-office365.c
e-oauth2-service-office365.h
- e-soup-auth-negotiate.c
- e-soup-auth-negotiate.h
e-soap-request.c
e-soap-request.h
e-soap-response.c
diff --git a/src/EWS/common/e-ews-camel-common.c b/src/EWS/common/e-ews-camel-common.c
index 1446eea3..4337e627 100644
--- a/src/EWS/common/e-ews-camel-common.c
+++ b/src/EWS/common/e-ews-camel-common.c
@@ -322,7 +322,7 @@ create_mime_message_cb (ESoapRequest *request,
}
e_ews_request_write_string_parameter_with_attribute (
- msg,
+ request,
"IsRead",
NULL,
(message_camel_flags & CAMEL_MESSAGE_SEEN) != 0 ? "true" : "false",
diff --git a/src/EWS/common/e-ews-connection-utils.c b/src/EWS/common/e-ews-connection-utils.c
index 76978fd7..e8fad0da 100644
--- a/src/EWS/common/e-ews-connection-utils.c
+++ b/src/EWS/common/e-ews-connection-utils.c
@@ -13,7 +13,6 @@
#include <glib/gstdio.h>
#include "e-ews-connection-utils.h"
-#include "e-soup-auth-negotiate.h"
#include "camel-ews-settings.h"
void
@@ -268,7 +267,7 @@ e_ews_connection_utils_prepare_auth_method (SoupSession *soup_session,
* enabled, which is the default configuration. It's a useful fallback
* which people may be relying on. */
if (auth_method == EWS_AUTH_TYPE_GSSAPI) {
- soup_session_add_feature_by_type (soup_session, E_SOUP_TYPE_AUTH_NEGOTIATE);
+ soup_session_add_feature_by_type (soup_session, SOUP_TYPE_AUTH_NEGOTIATE);
soup_session_remove_feature_by_type (soup_session, SOUP_TYPE_AUTH_BASIC);
} else if (auth_method == EWS_AUTH_TYPE_OAUTH2) {
soup_session_add_feature_by_type (soup_session, E_TYPE_SOUP_AUTH_BEARER);
@@ -277,316 +276,3 @@ e_ews_connection_utils_prepare_auth_method (SoupSession *soup_session,
soup_session_add_feature_by_type (soup_session, SOUP_TYPE_AUTH_NTLM);
}
}
-
-static void
-ews_connection_utils_ensure_bearer_auth_usage (SoupSession *session,
- SoupMessage *message,
- ESoupAuthBearer *bearer)
-{
- SoupAuthManager *auth_manager;
- SoupSessionFeature *feature;
- GUri *uri;
-
- g_return_if_fail (SOUP_IS_SESSION (session));
-
- /* Preload the SoupAuthManager with a valid "Bearer" token
- * when using OAuth 2.0. This avoids an extra unauthorized
- * HTTP round-trip, which apparently Google doesn't like. */
-
- feature = soup_session_get_feature (SOUP_SESSION (session), SOUP_TYPE_AUTH_MANAGER);
-
- if (!soup_session_has_feature (SOUP_SESSION (session), E_TYPE_SOUP_AUTH_BEARER)) {
- /* Add the "Bearer" auth type to support OAuth 2.0. */
- soup_session_add_feature_by_type (SOUP_SESSION (session), E_TYPE_SOUP_AUTH_BEARER);
- }
-
- uri = message ? soup_message_get_uri (message) : NULL;
- if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
- uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
- g_uri_get_scheme (uri),
- NULL /* userinfo */,
- g_uri_get_host (uri),
- g_uri_get_port (uri),
- NULL /* path */,
- NULL /* query */,
- NULL /* fragment */);
- } else {
- uri = NULL;
- }
-
- g_return_if_fail (uri != NULL);
-
- auth_manager = SOUP_AUTH_MANAGER (feature);
-
- /* This will make sure the 'bearer' is used regardless of the current 'auth_manager' state.
- See https://gitlab.gnome.org/GNOME/libsoup/-/issues/196 for more information. */
- soup_auth_manager_clear_cached_credentials (auth_manager);
- soup_auth_manager_use_auth (auth_manager, uri, SOUP_AUTH (bearer));
-
- g_uri_unref (uri);
-}
-
-static gboolean
-ews_connection_utils_setup_bearer_auth (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *message,
- gboolean is_in_authenticate_handler,
- ESoupAuthBearer *bearer,
- GCancellable *cancellable,
- GError **error)
-{
- ESource *source;
- gchar *access_token = NULL;
- gint expires_in_seconds = -1;
- gboolean success = FALSE;
-
- g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE);
- g_return_val_if_fail (E_IS_SOUP_AUTH_BEARER (bearer), FALSE);
-
- source = e_ews_connection_get_source (cnc);
-
- success = e_source_get_oauth2_access_token_sync (source, cancellable,
- &access_token, &expires_in_seconds, error);
-
- if (success) {
- e_soup_auth_bearer_set_access_token (bearer, access_token, expires_in_seconds);
-
- if (!is_in_authenticate_handler) {
- if (session)
- g_object_ref (session);
- else
- session = e_ews_connection_ref_soup_session (cnc);
-
- ews_connection_utils_ensure_bearer_auth_usage (session, message, bearer);
-
- g_clear_object (&session);
- }
- }
-
- g_free (access_token);
-
- return success;
-}
-
-static gboolean
-ews_connection_utils_maybe_prepare_bearer_auth (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *message,
- GCancellable *cancellable)
-{
- ESource *source;
- ESoupAuthBearer *using_bearer_auth;
- gchar *auth_method = NULL;
- gboolean success;
- GError *local_error = NULL;
-
- g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE);
-
- source = e_ews_connection_get_source (cnc);
- if (!source)
- return TRUE;
-
- if (e_source_has_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)) {
- ESourceAuthentication *extension;
-
- extension = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION);
- auth_method = e_source_authentication_dup_method (extension);
- } else {
- CamelEwsSettings *ews_settings;
-
- ews_settings = e_ews_connection_ref_settings (cnc);
- if (ews_settings) {
- if (camel_ews_settings_get_auth_mechanism (ews_settings) == EWS_AUTH_TYPE_OAUTH2)
- auth_method = g_strdup ("OAuth2");
-
- g_object_unref (ews_settings);
- }
-
- if (!auth_method)
- return TRUE;
- }
-
- if (g_strcmp0 (auth_method, "OAuth2") != 0 &&
- g_strcmp0 (auth_method, "Office365") != 0 &&
- !e_oauth2_services_is_oauth2_alias_static (auth_method)) {
- g_free (auth_method);
- return TRUE;
- }
-
- g_free (auth_method);
-
- using_bearer_auth = e_ews_connection_ref_bearer_auth (cnc);
- if (using_bearer_auth) {
- success = ews_connection_utils_setup_bearer_auth (cnc, session, message, FALSE,
using_bearer_auth, cancellable, &local_error);
- g_clear_object (&using_bearer_auth);
- } else {
- SoupAuth *soup_auth;
- GUri *uri;
-
- uri = message ? soup_message_get_uri (message) : NULL;
- if (uri && g_uri_get_host (uri) && *g_uri_get_host (uri)) {
- uri = g_uri_build (G_URI_FLAGS_PARSE_RELAXED,
- g_uri_get_scheme (uri),
- NULL /* userinfo */,
- g_uri_get_host (uri),
- g_uri_get_port (uri),
- NULL /* path */,
- NULL /* query */,
- NULL /* fragment */);
- } else {
- uri = NULL;
- }
-
- g_warn_if_fail (uri != NULL);
-
- if (!uri) {
- return FALSE;
- }
-
- soup_auth = g_object_new (E_TYPE_SOUP_AUTH_BEARER, NULL);
-
- success = ews_connection_utils_setup_bearer_auth (cnc, session, message, FALSE,
E_SOUP_AUTH_BEARER (soup_auth), cancellable, &local_error);
- if (success)
- e_ews_connection_set_bearer_auth (cnc, E_SOUP_AUTH_BEARER (soup_auth));
-
- g_object_unref (soup_auth);
- g_uri_unref (uri);
- }
-
- if (!success) {
- if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- soup_message_set_status (message, SOUP_STATUS_CANCELLED);
- else if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED) ||
- g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- soup_message_set_status_full (message, SOUP_STATUS_UNAUTHORIZED,
local_error->message);
- else
- soup_message_set_status_full (message, SOUP_STATUS_MALFORMED, local_error ?
local_error->message : _("Unknown error"));
- }
-
- g_clear_error (&local_error);
-
- return success;
-}
-
-/* Callback implementation for SoupSession::authenticate */
-void
-e_ews_connection_utils_authenticate (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *msg,
- SoupAuth *auth,
- gboolean retrying)
-{
- CamelNetworkSettings *network_settings;
- ESoupAuthBearer *using_bearer_auth;
- gchar *user, *password, *service_url = NULL;
- gboolean expired = FALSE;
-
- g_return_if_fail (cnc != NULL);
-
- using_bearer_auth = e_ews_connection_ref_bearer_auth (cnc);
-
- if (E_IS_SOUP_AUTH_BEARER (auth)) {
- g_object_ref (auth);
- g_warn_if_fail ((gpointer) using_bearer_auth == (gpointer) auth);
-
- g_clear_object (&using_bearer_auth);
- using_bearer_auth = E_SOUP_AUTH_BEARER (auth);
-
- e_ews_connection_set_bearer_auth (cnc, using_bearer_auth);
- }
-
- if (retrying)
- e_ews_connection_set_password (cnc, NULL);
-
- if (using_bearer_auth) {
- GError *local_error = NULL;
-
- ews_connection_utils_setup_bearer_auth (cnc, session, msg, TRUE, E_SOUP_AUTH_BEARER (auth),
NULL, &local_error);
-
- if (local_error)
- soup_message_set_status_full (msg, SOUP_STATUS_IO_ERROR, local_error->message);
-
- g_object_unref (using_bearer_auth);
- g_clear_error (&local_error);
-
- return;
- }
-
- if (e_ews_connection_utils_check_x_ms_credential_headers (msg, NULL, &expired, &service_url) &&
expired) {
- GError *local_error = NULL;
-
- e_ews_connection_utils_expired_password_to_error (service_url, &local_error);
-
- if (local_error)
- soup_message_set_status_full (msg, SOUP_STATUS_IO_ERROR, local_error->message);
-
- g_clear_error (&local_error);
- g_free (service_url);
-
- return;
- }
-
- g_free (service_url);
-
- network_settings = CAMEL_NETWORK_SETTINGS (e_ews_connection_ref_settings (cnc));
- user = camel_network_settings_dup_user (network_settings);
-
- password = e_ews_connection_dup_password (cnc);
- if (password != NULL) {
- soup_auth_authenticate (auth, user, password);
- } else {
- /* The NTLM implementation in libsoup doesn't cope very well
- * with recovering from authentication failures (bug 703181).
- * So cancel the message now while it's in-flight, and we'll
- * get a shiny new connection for the next attempt. */
- const gchar *scheme = soup_auth_get_scheme_name (auth);
-
- if (!g_ascii_strcasecmp(scheme, "NTLM")) {
- soup_session_cancel_message (session, msg, SOUP_STATUS_UNAUTHORIZED);
- }
- }
-
- g_clear_object (&network_settings);
- g_free (password);
- g_free (user);
-}
-
-/* Returns whether succeeded */
-gboolean
-e_ews_connection_utils_prepare_message (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *message,
- GCancellable *cancellable)
-{
- ESoupAuthBearer *using_bearer_auth;
- ESource *source;
- GError *local_error = NULL;
-
- source = e_ews_connection_get_source (cnc);
- if (source)
- e_soup_ssl_trust_connect (message, source);
-
- if (!ews_connection_utils_maybe_prepare_bearer_auth (cnc, session, message, cancellable))
- return FALSE;
-
- using_bearer_auth = e_ews_connection_ref_bearer_auth (cnc);
-
- if (using_bearer_auth &&
- e_soup_auth_bearer_is_expired (using_bearer_auth) &&
- !ews_connection_utils_setup_bearer_auth (cnc, session, message, FALSE, using_bearer_auth,
cancellable, &local_error)) {
- if (local_error) {
- soup_message_set_status_full (message, SOUP_STATUS_BAD_REQUEST, local_error->message);
- g_clear_error (&local_error);
- } else {
- soup_message_set_status (message, SOUP_STATUS_BAD_REQUEST);
- }
-
- g_object_unref (using_bearer_auth);
-
- return FALSE;
- }
-
- g_clear_object (&using_bearer_auth);
-
- return TRUE;
-}
diff --git a/src/EWS/common/e-ews-connection-utils.h b/src/EWS/common/e-ews-connection-utils.h
index 62335b87..d2365d14 100644
--- a/src/EWS/common/e-ews-connection-utils.h
+++ b/src/EWS/common/e-ews-connection-utils.h
@@ -38,15 +38,6 @@ gboolean e_ews_connection_utils_check_x_ms_credential_headers
void e_ews_connection_utils_prepare_auth_method
(SoupSession *soup_session,
EwsAuthType auth_method);
-void e_ews_connection_utils_authenticate (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *msg,
- SoupAuth *auth,
- gboolean retrying);
-gboolean e_ews_connection_utils_prepare_message (EEwsConnection *cnc,
- SoupSession *session,
- SoupMessage *message,
- GCancellable *cancellable);
G_END_DECLS
diff --git a/src/EWS/common/e-ews-connection.c b/src/EWS/common/e-ews-connection.c
index ce2a4f4f..1d6f5717 100644
--- a/src/EWS/common/e-ews-connection.c
+++ b/src/EWS/common/e-ews-connection.c
@@ -32,23 +32,17 @@
/* A chunk size limit when moving items in chunks. */
#define EWS_MOVE_ITEMS_CHUNK_SIZE 500
+/* For network stream reading */
+#define BUFFER_SIZE 16384
+
#define QUEUE_LOCK(x) (g_rec_mutex_lock(&(x)->priv->queue_lock))
#define QUEUE_UNLOCK(x) (g_rec_mutex_unlock(&(x)->priv->queue_lock))
#define NOTIFICATION_LOCK(x) (g_mutex_lock(&(x)->priv->notification_lock))
#define NOTIFICATION_UNLOCK(x) (g_mutex_unlock(&(x)->priv->notification_lock))
-struct _EwsNode;
static GMutex connecting;
static GHashTable *loaded_connections_permissions = NULL;
-static gint comp_func (gconstpointer a, gconstpointer b);
-
-static void ews_response_cb (SoupSession *session, SoupMessage *msg, gpointer data);
-
-static gboolean ews_connection_authenticate (SoupMessage *msg,
- SoupAuth *auth,
- gboolean retrying,
- gpointer data);
struct _EEwsSoupThreadData {
GMutex mutex;
@@ -197,6 +191,11 @@ e_ews_connection_create_soup_session (EEwsConnection *cnc)
"max-conns-per-host", cnc->priv->concurrent_connections,
NULL);
+ e_binding_bind_property (
+ cnc->priv->settings, "timeout",
+ session, "timeout",
+ G_BINDING_SYNC_CREATE);
+
e_binding_bind_property (
cnc, "proxy-resolver",
session, "proxy-resolver",
@@ -212,12 +211,12 @@ e_ews_connection_create_soup_session (EEwsConnection *cnc)
if (log_level >= 3)
soup_logger_set_printer (logger, e_ews_soup_log_printer, NULL, NULL);
- soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
+ soup_session_add_feature (SOUP_SESSION (session), SOUP_SESSION_FEATURE (logger));
g_object_unref (logger);
}
- soup_session_add_feature_by_type (session, SOUP_TYPE_COOKIE_JAR);
+ soup_session_add_feature_by_type (SOUP_SESSION (session), SOUP_TYPE_COOKIE_JAR);
return session;
}
@@ -236,7 +235,7 @@ e_ews_soup_worker_thread (gpointer user_data)
g_mutex_lock (&cnc->priv->soup.mutex);
cnc->priv->soup.session = SOUP_SESSION (e_ews_connection_create_soup_session (cnc));
- e_ews_connection_utils_prepare_auth_method (session,
+ e_ews_connection_utils_prepare_auth_method (cnc->priv->soup.session,
camel_ews_settings_get_auth_mechanism (settings));
g_cond_broadcast (&cnc->priv->soup.cond);
@@ -311,6 +310,7 @@ e_ews_connection_process_request_sync (EEwsConnection *cnc,
GError **error)
{
ProcessData pd;
+ const gchar *persistent_auth;
CamelEwsSettings *settings;
GSource *source;
@@ -329,10 +329,13 @@ e_ews_connection_process_request_sync (EEwsConnection *cnc,
}
g_mutex_unlock (&cnc->priv->soup.mutex);
- pd.message = e_soap_request_persist (request, E_SOUP_SESSION (cnc->priv->soup.session), settings);
+ pd.message = e_soap_request_persist (request, E_SOUP_SESSION (cnc->priv->soup.session), settings,
error);
g_clear_object (&settings);
+ if (!pd.message)
+ return NULL;
+
pd.prepare_data = e_soup_session_prepare_message_send_sync (E_SOUP_SESSION (cnc->priv->soup.session),
pd.message, cancellable, error);
if (!pd.prepare_data) {
@@ -364,6 +367,16 @@ e_ews_connection_process_request_sync (EEwsConnection *cnc,
g_mutex_unlock (&pd.mutex);
+ persistent_auth = soup_message_headers_get_one (soup_message_get_response_headers (pd.message),
"Persistent-Auth");
+ if (persistent_auth && g_ascii_strcasecmp (persistent_auth, "false") == 0) {
+ SoupSessionFeature *feature;
+
+ feature = soup_session_get_feature (cnc->priv->soup.session, SOUP_TYPE_AUTH_MANAGER);
+ if (feature) {
+ soup_auth_manager_clear_cached_credentials (SOUP_AUTH_MANAGER (feature));
+ }
+ }
+
if (pd.input_stream)
*out_message = g_steal_pointer (&pd.message);
@@ -390,7 +403,9 @@ ews_connection_credentials_failed (EEwsConnection *connection,
gchar *service_url = NULL;
g_return_val_if_fail (E_IS_EWS_CONNECTION (connection), FALSE);
- g_return_val_if_fail (SOUP_IS_MESSAGE (message), FALSE);
+
+ if (!message)
+ return FALSE;
if (!e_ews_connection_utils_check_x_ms_credential_headers (message, &expire_in_days, &expired,
&service_url))
return FALSE;
@@ -409,7 +424,7 @@ ews_connection_credentials_failed (EEwsConnection *connection,
static gboolean
e_ews_connection_handle_backoff_policy (EEwsConnection *cnc,
ESoapResponse *response,
- GCancelalble *cancellable,
+ GCancellable *cancellable,
GError **error)
{
ESoapParameter *param;
@@ -483,7 +498,7 @@ e_ews_connection_handle_backoff_policy (EEwsConnection *cnc,
e_flag_free (flag);
- repeat = !g_cancellable_set_error_if_cancelled (cancellable);
+ repeat = !g_cancellable_set_error_if_cancelled (cancellable, error);
}
return repeat;
@@ -504,7 +519,6 @@ e_ews_connection_send_request_sync (EEwsConnection *cnc,
GError *local_error = NULL;
while (repeat) {
- const gchar *persistent_auth;
GError *local_error2 = NULL;
repeat = FALSE;
@@ -513,31 +527,21 @@ e_ews_connection_send_request_sync (EEwsConnection *cnc,
input_stream = e_ews_connection_process_request_sync (cnc, request, &message,
&certificate_pem, &certificate_errors, cancellable, &local_error);
- persistent_auth = soup_message_headers_get_one (soup_message_get_response_headers (request),
"Persistent-Auth");
- if (persistent_auth && g_ascii_strcasecmp (persistent_auth, "false") == 0) {
- SoupSessionFeature *feature;
-
- feature = soup_session_get_feature (session, SOUP_TYPE_AUTH_MANAGER);
- if (feature) {
- soup_auth_manager_clear_cached_credentials (SOUP_AUTH_MANAGER (feature));
- }
- }
-
g_mutex_lock (&cnc->priv->property_lock);
g_clear_pointer (&cnc->priv->ssl_certificate_pem, g_free);
cnc->priv->ssl_info_set = certificate_pem != NULL;
cnc->priv->ssl_certificate_pem = g_strdup (certificate_pem);
- cnc->priov->ssl_certificate_errors = certificate_errors;
- g_mutex_unlock (&connection->priv->property_lock);
+ cnc->priv->ssl_certificate_errors = certificate_errors;
+ g_mutex_unlock (&cnc->priv->property_lock);
e_soap_request_take_tls_error_details (request, certificate_pem, certificate_errors);
- if (!ews_connection_credentials_failed (cnc, message, &local_error2)) {
- if (soup_message_get_status (request) == SOUP_STATUS_UNAUTHORIZED) {
- if (soup_message_get_response_headers (request)) {
+ if (message && !ews_connection_credentials_failed (cnc, message, &local_error2)) {
+ if (soup_message_get_status (message) == SOUP_STATUS_UNAUTHORIZED) {
+ if (soup_message_get_response_headers (message)) {
const gchar *diagnostics;
- diagnostics = soup_message_headers_get_list
(soup_message_get_response_headers (request), "X-MS-DIAGNOSTICS");
+ diagnostics = soup_message_headers_get_list
(soup_message_get_response_headers (message), "X-MS-DIAGNOSTICS");
if (diagnostics && strstr (diagnostics, "invalid_grant")) {
g_set_error_literal (&local_error2, EWS_CONNECTION_ERROR,
EWS_CONNECTION_ERROR_ACCESSDENIED, diagnostics);
} else if (diagnostics && *diagnostics) {
@@ -564,21 +568,16 @@ e_ews_connection_send_request_sync (EEwsConnection *cnc,
if (custom_process_fn) {
custom_process_fn (request, message, input_stream, custom_process_data,
&repeat, cancellable, &local_error);
} else {
- ESoapResponseProgressFn progress_fn = NULL;
- gpointer progress_data = NULL;
-
- e_soap_request_get_progress_fn (request, &progress_fn, &progress_data);
-
response = e_soap_response_new ();
- e_soap_response_set_progress_fn (request, progress_fn, progress_data);
+ e_soap_request_setup_response (request, response);
if (!e_soap_response_from_message_sync (response, message, input_stream,
cancellable, &local_error)) {
g_clear_object (&response);
if (!local_error) {
g_set_error (&local_error, EWS_CONNECTION_ERROR,
EWS_CONNECTION_ERROR_NORESPONSE,
- _("No response: %s"), soup_message_get_reason_phrase
(messsage));
+ _("No response: %s"), soup_message_get_reason_phrase
(message));
}
}
@@ -620,7 +619,7 @@ static gboolean
ews_update_concurrect_connections_cb (gpointer user_data)
{
GWeakRef *weak_ref = user_data;
- EEwsConnection *cnc = g_weak_ref_get (cnc);
+ EEwsConnection *cnc = g_weak_ref_get (weak_ref);
if (cnc) {
g_mutex_lock (&cnc->priv->soup.mutex);
@@ -919,12 +918,6 @@ e_ews_additional_props_free (EEwsAdditionalProps *add_props)
}
}
-static EwsNode *
-ews_node_new (void)
-{
- return g_slice_new0 (EwsNode);
-}
-
static void
autodiscover_parse_protocol (xmlNode *node,
EwsUrls *urls)
@@ -1184,8 +1177,6 @@ ews_connection_finalize (GObject *object)
g_free (cnc->priv->ssl_certificate_pem);
g_free (cnc->priv->last_subscription_id);
- g_clear_object (&cnc->priv->bearer_auth);
-
g_mutex_clear (&cnc->priv->property_lock);
g_rec_mutex_clear (&cnc->priv->queue_lock);
g_mutex_clear (&cnc->priv->notification_lock);
@@ -1336,21 +1327,6 @@ e_ews_connection_init (EEwsConnection *cnc)
g_mutex_init (&cnc->priv->notification_lock);
}
-static gboolean
-ews_connection_authenticate (SoupMessage *msg,
- SoupAuth *auth,
- gboolean retrying,
- gpointer data)
-{
- EEwsConnection *cnc = data;
-
- g_return_val_if_fail (cnc != NULL, TRUE);
-
- e_ews_connection_utils_authenticate (cnc, cnc->priv->soup_session, msg, auth, retrying);
-
- return TRUE;
-}
-
void
ews_oal_free (EwsOAL *oal)
{
@@ -1708,11 +1684,6 @@ e_ews_connection_new_full (ESource *source,
cnc->priv->impersonate_user = NULL;
}
- e_binding_bind_property (
- settings, "timeout",
- cnc->priv->soup_session, "timeout",
- G_BINDING_SYNC_CREATE);
-
if (allow_connection_reuse) {
/* add the connection to the loaded_connections_permissions hash table */
if (loaded_connections_permissions == NULL)
@@ -1852,7 +1823,7 @@ e_ews_connection_try_credentials_sync (EEwsConnection *cnc,
if (local_error == NULL) {
result = E_SOURCE_AUTHENTICATION_ACCEPTED;
- } else if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_SSL_FAILED) &&
+ } else if (g_error_matches (local_error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE) &&
e_ews_connection_get_ssl_error_details (cnc, out_certificate_pem, out_certificate_errors))
{
result = E_SOURCE_AUTHENTICATION_ERROR_SSL_FAILED;
} else {
@@ -1922,43 +1893,6 @@ e_ews_connection_get_uri (EEwsConnection *cnc)
return cnc->priv->uri;
}
-ESoupAuthBearer *
-e_ews_connection_ref_bearer_auth (EEwsConnection *cnc)
-{
- ESoupAuthBearer *bearer_auth;
-
- g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), NULL);
-
- g_mutex_lock (&cnc->priv->property_lock);
- bearer_auth = cnc->priv->bearer_auth;
- if (bearer_auth)
- g_object_ref (bearer_auth);
- g_mutex_unlock (&cnc->priv->property_lock);
-
- return bearer_auth;
-}
-
-void
-e_ews_connection_set_bearer_auth (EEwsConnection *cnc,
- ESoupAuthBearer *bearer_auth)
-{
- g_return_if_fail (E_IS_EWS_CONNECTION (cnc));
- if (bearer_auth)
- g_return_if_fail (E_IS_SOUP_AUTH_BEARER (bearer_auth));
-
- g_mutex_lock (&cnc->priv->property_lock);
-
- if (bearer_auth != cnc->priv->bearer_auth) {
- g_clear_object (&cnc->priv->bearer_auth);
- cnc->priv->bearer_auth = bearer_auth;
-
- if (cnc->priv->bearer_auth)
- g_object_ref (cnc->priv->bearer_auth);
- }
-
- g_mutex_unlock (&cnc->priv->property_lock);
-}
-
const gchar *
e_ews_connection_get_password (EEwsConnection *cnc)
{
@@ -2068,14 +2002,6 @@ e_ews_connection_ref_settings (EEwsConnection *cnc)
return g_object_ref (cnc->priv->settings);
}
-SoupSession *
-e_ews_connection_ref_soup_session (EEwsConnection *cnc)
-{
- g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), NULL);
-
- return g_object_ref (cnc->priv->soup_session);
-}
-
gboolean
e_ews_connection_get_backoff_enabled (EEwsConnection *cnc)
{
@@ -2317,13 +2243,14 @@ typedef struct _AutodiscoverData {
GCancellable *cancellable;
/* Allocated */
- xmlOutputBuffer *buf
+ xmlOutputBuffer *buf;
gchar *redirect_addr;
gchar *redirect_url;
gint n_redirects;
/* Results */
+ gboolean success;
gchar *certificate_pem;
GTlsCertificateFlags certificate_errors;
GError *error;
@@ -2368,7 +2295,7 @@ e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
static void
ews_process_autodiscover_response (AutodiscoverData *ad,
- GBytes *bytes,
+ GByteArray *bytes,
GError **error)
{
@@ -2376,15 +2303,14 @@ ews_process_autodiscover_response (AutodiscoverData *ad,
xmlDoc *doc;
xmlNode *node;
gchar *str;
- gint idx;
+
+ g_return_if_fail (bytes != NULL);
memset (&exch_urls, 0, sizeof (EwsUrls));
memset (&expr_urls, 0, sizeof (EwsUrls));
- doc = xmlReadMemory (
- g_bytes_get_data (bytes, NULL),
- g_bytes_get_size (bytes),
- "autodiscover.xml", NULL, 0);
+ doc = xmlReadMemory ((const gchar *) bytes->data, bytes->len, "autodiscover.xml", NULL, 0);
+
if (!doc) {
g_set_error_literal (error, EWS_CONNECTION_ERROR, -1,
_("Failed to parse autodiscover response XML"));
@@ -2462,6 +2388,8 @@ ews_process_autodiscover_response (AutodiscoverData *ad,
goto failed;
}
+ ad->success = TRUE;
+
/* It's a good response, cancel all pending */
g_cancellable_cancel (ad->cancellable);
@@ -2536,13 +2464,9 @@ e_ews_create_request_for_url (const gchar *url,
return NULL;
}
- request = e_soap_request_new (buf ? SOUP_METHOD_POST : SOUP_METHOD_GET, uri, FALSE, NULL, NULL, NULL);
- if (!request) {
- g_set_error (
- error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("URL โ%sโ is not valid"), url);
+ request = e_soap_request_new (buf ? SOUP_METHOD_POST : SOUP_METHOD_GET, url, FALSE, NULL, NULL, NULL,
error);
+ if (!request)
return NULL;
- }
if (buf) {
e_soap_request_set_custom_body (request, "text/xml; charset=utf-8",
@@ -2658,14 +2582,14 @@ e_ews_autodiscover_prepare_requests (AutodiscoverData *ad,
#undef process_url
- if (!is_outlook && *domain && requests && out_srv_lookup_domain)
+ if (local_error && requests)
+ g_clear_error (&local_error);
+
+ if (!is_outlook && !local_error && *domain && requests && out_srv_lookup_domain)
*out_srv_lookup_domain = g_strdup (domain);
else if (out_srv_lookup_domain)
*out_srv_lookup_domain = NULL;
- if (local_error && requests)
- g_clear_error (&local_error);
-
g_free (url1);
g_free (url2);
g_free (url3);
@@ -2674,27 +2598,35 @@ e_ews_autodiscover_prepare_requests (AutodiscoverData *ad,
if (local_error) {
xmlOutputBufferClose (buf);
g_propagate_error (error, local_error);
- return FALSE;
+ return NULL;
}
g_clear_pointer (&ad->buf, xmlOutputBufferClose);
ad->buf = buf;
- return TRUE;
+ return requests;
}
+typedef struct _AutodiscoverResponseData {
+ AutodiscoverData *ad;
+ SoupMessage *message;
+} AutodiscoverResponseData;
+
static void
-ews_autodiscover_response_ready_cb (GObject source_object,
+ews_autodiscover_response_ready_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- AutodiscoverData *ad = user_data;
+ AutodiscoverResponseData *ard = user_data;
+ AutodiscoverData *ad;
gchar *certificate_pem = NULL;
GTlsCertificateFlags certificate_errors = 0;
GInputStream *input_stream;
GError *local_error = NULL;
- g_return_if_fail (ad != NULL);
+ g_return_if_fail (ard != NULL);
+
+ ad = ard->ad;
input_stream = e_soup_session_send_message_finish (E_SOUP_SESSION (source_object), result,
&certificate_pem, &certificate_errors, &local_error);
@@ -2706,7 +2638,7 @@ ews_autodiscover_response_ready_cb (GObject source_object,
gsize nread = 0;
gboolean success;
- expected_length = soup_message_headers_get_content_length (soup_message_get_response_headers
(message));
+ expected_length = soup_message_headers_get_content_length (soup_message_get_response_headers
(ard->message));
if (expected_length > 0)
bytes = g_byte_array_sized_new (expected_length > 1024 * 1024 * 10 ? 1024 * 1024 * 10
: expected_length);
else
@@ -2714,7 +2646,7 @@ ews_autodiscover_response_ready_cb (GObject source_object,
buffer = g_malloc (BUFFER_SIZE);
- while (success = g_input_stream_read_all (input_stream, buffer, BUFFER_SIZE, &nread,
cancellable, &local_error),
+ while (success = g_input_stream_read_all (input_stream, buffer, BUFFER_SIZE, &nread,
ad->cancellable, &local_error),
success && nread > 0) {
g_byte_array_append (bytes, buffer, nread);
}
@@ -2739,8 +2671,11 @@ ews_autodiscover_response_ready_cb (GObject source_object,
g_clear_error (&local_error);
}
- if (!g_atomic_int_dec_and_test (&ad->n_requests))
+ if (!g_atomic_int_dec_and_test (&ad->n_pending))
g_main_loop_quit (ad->main_loop);
+
+ g_object_unref (ard->message);
+ g_slice_free (AutodiscoverResponseData, ard);
}
static void
@@ -2759,16 +2694,76 @@ ews_autodiscover_send_request (AutodiscoverData *ad,
prepare_data = e_soup_session_prepare_message_send_sync (ad->session, message, cancellable,
error);
if (prepare_data) {
- g_atomic_int_inc (&ad->n_requests);
+ AutodiscoverResponseData *ard;
+
+ g_atomic_int_inc (&ad->n_pending);
+
+ ard = g_slice_new (AutodiscoverResponseData);
+ ard->ad = ad;
+ ard->message = g_object_ref (message);
e_soup_session_send_message (ad->session, message, G_PRIORITY_DEFAULT, prepare_data,
- ad->cancellable, ews_autodiscover_response_ready_cb, ad);
+ ad->cancellable, ews_autodiscover_response_ready_cb, ard);
}
g_object_unref (message);
}
}
+static void
+autodiscover_srv_record_resolved_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GList *targets, *link;
+ AutodiscoverData *ad = user_data;
+ gchar *new_uri = NULL;
+ gboolean success;
+
+ g_return_if_fail (ad != NULL);
+
+ targets = g_resolver_lookup_service_finish (G_RESOLVER (source), result, NULL);
+
+ success = !g_cancellable_is_cancelled (ad->cancellable) && targets;
+
+ for (link = targets; link && success; link = g_list_next (link)) {
+ GSrvTarget *target = link->data;
+ const gchar *hostname;
+
+ hostname = g_srv_target_get_hostname (target);
+
+ switch (g_srv_target_get_port (target)) {
+ case 80:
+ link = NULL;
+ new_uri = g_strdup_printf ("http://%s/autodiscover/autodiscover.xml", hostname);
+ break;
+ case 443:
+ link = NULL;
+ new_uri = g_strdup_printf ("https://%s/autodiscover/autodiscover.xml", hostname);
+ break;
+ }
+ }
+
+ g_list_free_full (targets, (GDestroyNotify) g_srv_target_free);
+
+ if (new_uri && success) {
+ ESoapRequest *request = e_ews_create_request_for_url (new_uri, ad->buf, ad->error ? NULL :
&ad->error);
+ if (request) {
+ ews_autodiscover_send_request (ad, request, ad->cancellable, ad->error ? NULL :
&ad->error);
+ g_object_unref (request);
+ } else {
+ success = FALSE;
+ }
+ } else {
+ success = FALSE;
+ }
+
+ if (!success && !g_atomic_int_dec_and_test (&ad->n_pending))
+ g_main_loop_quit (ad->main_loop);
+
+ g_free (new_uri);
+}
+
static gboolean
e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
const gchar *email_address,
@@ -2782,7 +2777,7 @@ e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
g_return_val_if_fail (ad != NULL, FALSE);
/* to not have the main loop quit while doing this */
- g_atomic_int_inc (&ad->n_requests);
+ g_atomic_int_inc (&ad->n_pending);
/* This is starting a new round, the last error and others are obsolete */
g_clear_error (&ad->error);
@@ -2794,9 +2789,9 @@ e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
requests = e_ews_autodiscover_prepare_requests (ad, email_address, override_url, &srv_lookup_domain,
&local_error);
if (!local_error && srv_lookup_domain && *srv_lookup_domain) {
- g_atomic_int_inc (&ad->n_requests);
+ g_atomic_int_inc (&ad->n_pending);
- g_resolver_lookup_service_async (g_resolver_get_default (), "autodiscover", "tcp", domain,
cancellable,
+ g_resolver_lookup_service_async (g_resolver_get_default (), "autodiscover", "tcp",
srv_lookup_domain, cancellable,
autodiscover_srv_record_resolved_cb, ad);
}
@@ -2816,7 +2811,7 @@ e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
}
/* pair decrement for the increment at the beginning of the function */
- if (!g_atomic_int_dec_and_test (&ad->n_requests))
+ if (!g_atomic_int_dec_and_test (&ad->n_pending))
g_main_loop_quit (ad->main_loop);
g_slist_free_full (requests, g_object_unref);
@@ -2826,66 +2821,36 @@ e_ews_autodiscover_prepare_requests_and_send_sync (AutodiscoverData *ad,
}
static void
-autodiscover_srv_record_resolved_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
+e_ews_cancel_cancellable_cb (GCancellable *cancellable,
+ gpointer user_data)
{
- GList *targets, *link;
- AutodiscoverData *ad = user_data;
- gchar *new_uri = NULL;
- gboolean success;
+ GCancellable *op_cancellable = user_data;
- g_return_if_fail (ad != NULL);
+ g_cancellable_cancel (op_cancellable);
+}
- targets = g_resolver_lookup_service_finish (G_RESOLVER (source), result, NULL);
+static gboolean
+has_suffix_icmp (const gchar *text,
+ const gchar *suffix)
+{
+ gint ii, tlen, slen;
- success = !g_cancellable_is_cancelled (ad->cancellable) && targets;
+ g_return_val_if_fail (text != NULL, FALSE);
+ g_return_val_if_fail (suffix != NULL, FALSE);
- for (link = targets; link && success; link = g_list_next (link)) {
- GSrvTarget *target = link->data;
- const gchar *hostname;
+ tlen = strlen (text);
+ slen = strlen (suffix);
- hostname = g_srv_target_get_hostname (target);
+ if (!*text || !*suffix || tlen < slen)
+ return FALSE;
- switch (g_srv_target_get_port (target)) {
- case 80:
- link = NULL;
- new_uri = g_strdup_printf ("http://%s/autodiscover/autodiscover.xml", hostname);
- break;
- case 443:
- link = NULL;
- new_uri = g_strdup_printf ("https://%s/autodiscover/autodiscover.xml", hostname);
+ for (ii = 0; ii < slen; ii++) {
+ if (g_ascii_tolower (text[tlen - ii - 1]) !=
+ g_ascii_tolower (suffix[slen - ii - 1]))
break;
- }
- }
-
- g_list_free_full (targets, (GDestroyNotify) g_srv_target_free);
-
- if (new_uri && success) {
- ESoapRequest *request = e_ews_create_request_for_url (new_uri, ad->buf, ad->error ? NULL :
&ad->error);
- if (request)
- ews_autodiscover_send_request (ad, request, ad->cancellable, ad->error ? NULL :
&ad->error);
- g_object_unref (request);
- } else {
- success = FALSE;
- }
- } else {
- success = FALSE;
}
- if (!success && !g_atomic_int_dec_and_test (&ad->n_requests))
- g_main_loop_quit (ad->main_loop);
-
- g_free (new_uri);
-}
-
-static void
-autodiscover_cancelled_cb (GCancellable *cancellable,
- gpointer user_data)
-{
- GCancellable *op_cancellable = user_data;
-
- g_cancellable_cancel (op_cancellable);
+ return ii == slen;
}
gboolean
@@ -2901,9 +2866,9 @@ e_ews_autodiscover_ws_url_sync (ESource *source,
AutodiscoverData ad;
gulong cancelled_id = 0;
EEwsConnection *tmp_cnc;
+ GMainContext *main_context;
const gchar *domain;
const gchar *host_url;
- GError *local_error = NULL;
g_return_val_if_fail (CAMEL_IS_EWS_SETTINGS (settings), FALSE);
g_return_val_if_fail (email_address != NULL, FALSE);
@@ -2923,13 +2888,13 @@ e_ews_autodiscover_ws_url_sync (ESource *source,
ad.cancellable = g_cancellable_new ();
if (G_IS_CANCELLABLE (cancellable)) {
- cancelled_id = g_cancellable_connect (cancellable, G_CALLBACK (autodiscover_cancelled_cb),
+ cancelled_id = g_cancellable_connect (cancellable, G_CALLBACK (e_ews_cancel_cancellable_cb),
ad.cancellable, NULL);
}
- ad.main_context = g_main_context_new ();
- ad.main_loop = g_main_loop_new (ad.main_context, FALSE);
- g_main_context_push_thread_default (ad.main_context);
+ main_context = g_main_context_new ();
+ ad.main_loop = g_main_loop_new (main_context, FALSE);
+ g_main_context_push_thread_default (main_context);
/*
* http://msdn.microsoft.com/en-us/library/ee332364.aspx says we are
@@ -2949,9 +2914,9 @@ e_ews_autodiscover_ws_url_sync (ESource *source,
if (e_ews_autodiscover_prepare_requests_and_send_sync (&ad, email_address, host_url, cancellable))
g_main_loop_run (ad.main_loop);
- g_main_context_pop_thread_default (ad.main_context);
+ g_main_context_pop_thread_default (main_context);
- g_main_context_unref (ad.main_context);
+ g_main_context_unref (main_context);
g_main_loop_unref (ad.main_loop);
g_clear_object (&tmp_cnc);
g_clear_object (&ad.session);
@@ -2996,86 +2961,6 @@ e_ews_autodiscover_ws_url_sync (ESource *source,
return ad.success;
}
-static gboolean
-has_suffix_icmp (const gchar *text,
- const gchar *suffix)
-{
- gint ii, tlen, slen;
-
- g_return_val_if_fail (text != NULL, FALSE);
- g_return_val_if_fail (suffix != NULL, FALSE);
-
- tlen = strlen (text);
- slen = strlen (suffix);
-
- if (!*text || !*suffix || tlen < slen)
- return FALSE;
-
- for (ii = 0; ii < slen; ii++) {
- if (g_ascii_tolower (text[tlen - ii - 1]) !=
- g_ascii_tolower (suffix[slen - ii - 1]))
- break;
- }
-
- return ii == slen;
-}
-
-gboolean
-e_ews_autodiscover_ws_url_finish (CamelEwsSettings *settings,
- GAsyncResult *result,
- gchar **out_certificate_pem,
- GTlsCertificateFlags *out_certificate_errors,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- struct _autodiscover_data *ad;
- GError *local_error = NULL;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (settings),
- e_ews_autodiscover_ws_url), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- ad = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (g_simple_async_result_propagate_error (simple, &local_error)) {
- if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_SSL_FAILED)) {
- if (!e_ews_connection_get_ssl_error_details (ad->cnc, out_certificate_pem,
out_certificate_errors)) {
- if (out_certificate_pem)
- *out_certificate_pem = NULL;
- if (out_certificate_errors)
- *out_certificate_errors = 0;
- }
- }
-
- g_propagate_error (error, local_error);
-
- return FALSE;
- }
-
- g_warn_if_fail (ad->as_url != NULL);
- g_warn_if_fail (ad->oab_url != NULL);
-
- camel_ews_settings_set_hosturl (settings, ad->as_url);
-
- if (!has_suffix_icmp (ad->oab_url, "oab.xml")) {
- gchar *tmp;
-
- if (g_str_has_suffix (ad->oab_url, "/"))
- tmp = g_strconcat (ad->oab_url, "oab.xml", NULL);
- else
- tmp = g_strconcat (ad->oab_url, "/", "oab.xml", NULL);
-
- camel_ews_settings_set_oaburl (settings, tmp);
- g_free (tmp);
- } else {
- camel_ews_settings_set_oaburl (settings, ad->oab_url);
- }
-
- return TRUE;
-}
-
typedef struct _OalRequestData {
const gchar *oal_id;
const gchar *oal_element;
@@ -3175,9 +3060,8 @@ parse_oal_full_details (xmlNode *node,
return elements;
}
-/* this is run in cnc->priv->soup_thread */
static void
-e_ews_process_oal_data_response (ESoupaRequest *request,
+e_ews_process_oal_data_response (ESoapRequest *request,
SoupMessage *message,
GInputStream *input_stream,
gpointer user_data,
@@ -3187,16 +3071,13 @@ e_ews_process_oal_data_response (ESoupaRequest *request,
{
OalRequestData *req_data = user_data;
ESoapResponse *response;
- ESoapResponseProgressFn progress_fn = NULL;
- gpointer progress_data = NULL;
const gchar *etag;
xmlDoc *doc;
-
- e_soap_request_get_progress_fn (request, &progress_fn, &progress_data);
+ xmlNode *node;
response = e_soap_response_new ();
- e_soap_response_set_progress_fn (request, progress_fn, progress_data);
+ e_soap_request_setup_response (request, response);
doc = e_soap_response_xmldoc_from_message_sync (response, message, input_stream, cancellable, error);
@@ -3208,14 +3089,12 @@ e_ews_process_oal_data_response (ESoupaRequest *request,
return;
}
- etag = soup_message_headers_get_one (soup_message_get_response_headers (soup_message), "ETag");
+ etag = soup_message_headers_get_one (soup_message_get_response_headers (message), "ETag");
if (etag)
req_data->etag = g_strdup (etag);
node = xmlDocGetRootElement (doc);
if (strcmp ((gchar *) node->name, "OAB") == 0) {
- xmlNode *node;
-
for (node = node->children; node; node = node->next) {
if (node->type == XML_ELEMENT_NODE && strcmp ((gchar *) node->name, "OAL") == 0) {
if (req_data->oal_id == NULL) {
@@ -3250,13 +3129,6 @@ e_ews_process_oal_data_response (ESoupaRequest *request,
xmlFreeDoc (doc);
}
-static void
-ews_cancel_msg (GCancellable *cancellable,
- struct _oal_req_data *data)
-{
- ews_connection_schedule_cancel_message (data->cnc, data->soup_message);
-}
-
gboolean
e_ews_connection_get_oal_list_sync (EEwsConnection *cnc,
GSList **out_oals,
@@ -3291,7 +3163,7 @@ e_ews_connection_get_oal_list_sync (EEwsConnection *cnc,
if (!local_error)
*out_oals = g_steal_pointer (&req_data.oals);
- oal_req_data_clear (&req_data);
+ oal_request_data_clear (&req_data);
if (local_error) {
g_propagate_error (error, local_error);
@@ -3362,7 +3234,7 @@ e_ews_connection_get_oal_detail_sync (EEwsConnection *cnc,
*out_etag = g_steal_pointer (&req_data.etag);
}
- oal_req_data_clear (&req_data);
+ oal_request_data_clear (&req_data);
if (local_error) {
g_propagate_error (error, local_error);
@@ -3372,48 +3244,13 @@ e_ews_connection_get_oal_detail_sync (EEwsConnection *cnc,
return TRUE;
}
-static void
-ews_soup_got_chunk (SoupMessage *msg,
- SoupBuffer *chunk,
- gpointer user_data)
-{
- struct _oal_req_data *data = (struct _oal_req_data *) user_data;
- gint fd;
-
- if (msg->status_code != SOUP_STATUS_OK)
- return;
-
- data->received_size += chunk->length;
-
- if (data->response_size && data->progress_fn) {
- gint pc = data->received_size * 100 / data->response_size;
- data->progress_fn (data->progress_data, pc);
- }
-
- fd = g_open (data->cache_filename, O_RDONLY | O_WRONLY | O_APPEND | O_CREAT, 0600);
- if (fd != -1) {
- if (write (fd, (const gchar *) chunk->data, chunk->length) != chunk->length) {
- g_set_error (
- &data->error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_UNKNOWN,
- "Failed to write streaming data to file '%s': %s", data->cache_filename,
g_strerror (errno));
- }
- close (fd);
- } else {
- g_set_error (
- &data->error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_UNKNOWN,
- "Failed to open the cache file '%s': %s", data->cache_filename, g_strerror (errno));
- }
-}
-
typedef struct _DownloadOalData {
const gchar *cache_filename;
gint fd;
} DownloadOalData;
-#define BUFFER_SIZE 16384
-
static void
-e_ews_process_download_oal_file_response (ESoupaRequest *request,
+e_ews_process_download_oal_file_response (ESoapRequest *request,
SoupMessage *message,
GInputStream *input_stream,
gpointer user_data,
@@ -3430,13 +3267,14 @@ e_ews_process_download_oal_file_response (ESoupaRequest *request,
gsize response_received = 0;
gsize progress_percent = 0;
gsize nread = 0;
+ gboolean success;
g_return_if_fail (dod != NULL);
g_return_if_fail (dod->fd != -1);
e_soap_request_get_progress_fn (request, &progress_fn, &progress_data);
- size = soup_message_headers_get_one (soup_message_get_response_headers (soup_msg), "Content-Length");
+ size = soup_message_headers_get_one (soup_message_get_response_headers (message), "Content-Length");
if (size)
response_size = g_ascii_strtoll (size, NULL, 10);
@@ -3489,7 +3327,7 @@ e_ews_connection_download_oal_file_sync (EEwsConnection *cnc,
g_unlink (cache_filename);
dod.cache_filename = cache_filename;
- dod.fd = g_open (data->cache_filename, O_RDONLY | O_WRONLY | O_APPEND | O_CREAT, 0600);
+ dod.fd = g_open (cache_filename, O_RDONLY | O_WRONLY | O_APPEND | O_CREAT, 0600);
if (dod.fd == -1) {
g_set_error (error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_UNKNOWN,
"Failed to open the cache file '%s': %s", cache_filename, g_strerror (errno));
@@ -3663,7 +3501,7 @@ e_ews_process_sync_folder_items_response (EEwsConnection *cnc,
ESoapParameter *subparam;
GError *local_error = NULL;
- param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &lcoal_error);
+ param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &local_error);
/* Sanity check */
g_return_val_if_fail (
@@ -3726,7 +3564,12 @@ e_ews_connection_sync_folder_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
e_soap_request_start_element (request, "ItemShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, default_props);
@@ -3738,8 +3581,8 @@ e_ews_connection_sync_folder_items_sync (EEwsConnection *cnc,
e_ews_request_write_string_parameter_with_attribute (request, "FolderId", NULL, NULL, "Id", fid);
e_soap_request_end_element (request);
- if (last_sync_state)
- e_ews_request_write_string_parameter (request, "SyncState", "messages", last_sync_state);
+ if (old_sync_state)
+ e_ews_request_write_string_parameter (request, "SyncState", "messages", old_sync_state);
/* Max changes requested */
e_ews_request_write_int_parameter (request, "MaxChangesReturned", "messages", max_entries);
@@ -3773,7 +3616,7 @@ ews_append_folder_ids_to_msg (ESoapRequest *request,
for (l = folder_ids; l != NULL; l = g_slist_next (l)) {
const EwsFolderId *fid = l->data;
- e_ews_folder_id_append_to_msg (request, email, fid);
+ e_ews_folder_id_append_to_request (request, email, fid);
}
}
@@ -3831,7 +3674,7 @@ e_ews_process_find_folder_items_response (EEwsConnection *cnc,
if (E_EWS_CONNECTION_UTILS_CHECK_ELEMENT (name, "FindItemResponseMessage")) {
ESoapParameter *node, *subparam1;
- gchar *last, *total;
+ gchar *last;
EEwsItem *item;
gboolean includes_last_item;
@@ -3896,7 +3739,12 @@ e_ews_connection_find_folder_items_sync (EEwsConnection *cnc,
"Shallow",
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
e_soap_request_start_element (request, "ItemShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, default_props);
@@ -3982,7 +3830,7 @@ e_ews_process_sync_hierarchy_response (EEwsConnection *cnc,
/* Sanity check */
g_return_val_if_fail (
(param != NULL && local_error == NULL) ||
- (param == NULL && lcoal_error != NULL), FALSE);
+ (param == NULL && local_error != NULL), FALSE);
if (local_error != NULL) {
g_propagate_error (error, local_error);
@@ -4025,7 +3873,7 @@ e_ews_connection_sync_folder_hierarchy_sync (EEwsConnection *cnc,
ESoapResponse *response;
gboolean success;
- g_return_if_fail (cnc != NULL);
+ g_return_val_if_fail (cnc != NULL, FALSE);
request = e_ews_request_new_with_header (
cnc->priv->uri,
@@ -4035,7 +3883,12 @@ e_ews_connection_sync_folder_hierarchy_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, "AllProperties");
e_soap_request_start_element (request, "AdditionalProperties", NULL, NULL);
@@ -4046,8 +3899,8 @@ e_ews_connection_sync_folder_hierarchy_sync (EEwsConnection *cnc,
e_soap_request_end_element (request); /* AdditionalProperties */
e_soap_request_end_element (request); /* FolderShape */
- if (sync_state)
- e_ews_request_write_string_parameter (request, "SyncState", "messages", sync_state);
+ if (old_sync_state)
+ e_ews_request_write_string_parameter (request, "SyncState", "messages", old_sync_state);
e_ews_request_write_footer (request);
@@ -4058,8 +3911,8 @@ e_ews_connection_sync_folder_hierarchy_sync (EEwsConnection *cnc,
return FALSE;
}
- success = e_ews_process_sync_hierarchy_response (cnc, response, out_new_sync_state,
out_includes_last_item,
- out_items_created, out_items_updated, out_items_deleted, error);
+ success = e_ews_process_sync_hierarchy_response (cnc, response, out_new_sync_state,
out_includes_last_folder,
+ out_folders_created, out_folders_updated, out_folders_deleted, error);
g_clear_object (&request);
g_clear_object (&response);
@@ -4129,7 +3982,7 @@ static gboolean
e_ews_process_get_items_response (EEwsConnection *cnc,
ESoapResponse *response,
GSList **out_items,
- GError *error)
+ GError **error)
{
ESoapParameter *param;
ESoapParameter *subparam;
@@ -4233,7 +4086,11 @@ e_ews_connection_get_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (progress_fn && progress_data)
e_soap_request_set_progress_fn (request, progress_fn, progress_data);
@@ -4246,7 +4103,7 @@ e_ews_connection_get_items_sync (EEwsConnection *cnc,
else
e_ews_request_write_string_parameter (request, "IncludeMimeContent", NULL, "false");
if (mime_directory)
- e_soap_request_store_node_data (request, "MimeContent", mime_directory, TRUE);
+ e_soap_request_set_store_node_data (request, "MimeContent", mime_directory, TRUE);
switch (body_type) {
case E_EWS_BODY_TYPE_BEST:
@@ -4350,12 +4207,11 @@ e_ews_connection_delete_items_sync (EEwsConnection *cnc,
{
ESoapRequest *request;
ESoapResponse *response;
+ const GSList *link;
gboolean success;
g_return_val_if_fail (cnc != NULL, FALSE);
- closure = e_async_closure_new ();
-
request = e_ews_request_new_with_header (
cnc->priv->uri,
cnc->priv->impersonate_user,
@@ -4364,7 +4220,11 @@ e_ews_connection_delete_items_sync (EEwsConnection *cnc,
ews_delete_type_to_str (delete_type),
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (send_cancels)
e_soap_request_add_attribute (request, "SendMeetingCancellations",
@@ -4376,8 +4236,8 @@ e_ews_connection_delete_items_sync (EEwsConnection *cnc,
e_soap_request_start_element (request, "ItemIds", "messages", NULL);
- for (iter = ids; iter != NULL; iter = g_slist_next (iter)) {
- e_ews_request_write_string_parameter_with_attribute (request, "ItemId", NULL, NULL, "Id",
iter->data);
+ for (link = ids; link; link = g_slist_next (link)) {
+ e_ews_request_write_string_parameter_with_attribute (request, "ItemId", NULL, NULL, "Id",
link->data);
}
e_soap_request_end_element (request);
@@ -4416,6 +4276,7 @@ e_ews_connection_delete_item_sync (EEwsConnection *cnc,
gboolean success;
g_return_val_if_fail (cnc != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
request = e_ews_request_new_with_header (
cnc->priv->uri,
@@ -4425,7 +4286,11 @@ e_ews_connection_delete_item_sync (EEwsConnection *cnc,
ews_delete_type_to_str (delete_type),
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (send_cancels)
e_soap_request_add_attribute (request, "SendMeetingCancellations",
@@ -4439,17 +4304,17 @@ e_ews_connection_delete_item_sync (EEwsConnection *cnc,
if (index) {
e_soap_request_start_element (request, "OccurrenceItemId", NULL, NULL);
- e_soap_request_add_attribute (request, "RecurringMasterId", item_id->id, NULL, NULL);
- if (item_id->change_key)
- e_soap_request_add_attribute (request, "ChangeKey", item_id->change_key, NULL, NULL);
+ e_soap_request_add_attribute (request, "RecurringMasterId", id->id, NULL, NULL);
+ if (id->change_key)
+ e_soap_request_add_attribute (request, "ChangeKey", id->change_key, NULL, NULL);
snprintf (buffer, 32, "%u", index);
e_soap_request_add_attribute (request, "InstanceIndex", buffer, NULL, NULL);
e_soap_request_end_element (request);
} else {
e_soap_request_start_element (request, "ItemId", NULL, NULL);
- e_soap_request_add_attribute (request, "Id", item_id->id, NULL, NULL);
- if (item_id->change_key)
- e_soap_request_add_attribute (request, "ChangeKey", item_id->change_key, NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", id->id, NULL, NULL);
+ if (id->change_key)
+ e_soap_request_add_attribute (request, "ChangeKey", id->change_key, NULL, NULL);
e_soap_request_end_element (request);
}
@@ -4643,7 +4508,11 @@ e_ews_connection_update_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (conflict_res)
e_soap_request_add_attribute (request, "ConflictResolution", conflict_res, NULL, NULL);
@@ -4727,7 +4596,11 @@ e_ews_connection_create_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (msg_disposition)
e_soap_request_add_attribute (request, "MessageDisposition", msg_disposition, NULL, NULL);
@@ -4736,7 +4609,7 @@ e_ews_connection_create_items_sync (EEwsConnection *cnc,
if (fid) {
e_soap_request_start_element (request, "SavedItemFolderId", "messages", NULL);
- e_ews_folder_id_append_to_msg (request, cnc->priv->email, fid);
+ e_ews_folder_id_append_to_request (request, cnc->priv->email, fid);
e_soap_request_end_element (request);
}
@@ -4830,8 +4703,6 @@ e_ews_process_resolve_names_response (EEwsConnection *cnc,
if (E_EWS_CONNECTION_UTILS_CHECK_ELEMENT (name, "ResolveNamesResponseMessage")) {
ESoapParameter *node;
gchar *prop;
- gboolean includes_last_item;
- GSList *mailboxes = NULL, *contact_items = NULL;
subparam = e_soap_parameter_get_first_child_by_name (subparam, "ResolutionSet");
prop = e_soap_parameter_get_property (subparam, "IncludesLastItemInRange");
@@ -4870,6 +4741,8 @@ e_ews_process_resolve_names_response (EEwsConnection *cnc,
subparam = e_soap_parameter_get_next_child (subparam);
}
+
+ return TRUE;
}
gboolean
@@ -4901,7 +4774,11 @@ e_ews_connection_resolve_names_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_add_attribute (request, "SearchScope", get_search_scope_str (scope), NULL, NULL);
@@ -5118,10 +4995,10 @@ e_ews_connection_ex_to_smtp_sync (EEwsConnection *cnc,
}
static gboolean
-e_ews_process_expand_dl_response (EEwsConnectoon *cnc,
+e_ews_process_expand_dl_response (EEwsConnection *cnc,
ESoapResponse *response,
gboolean *out_includes_last_item,
- GSList *out_mailboxes,
+ GSList **out_mailboxes,
GError **error)
{
ESoapParameter *param;
@@ -5206,7 +5083,11 @@ e_ews_connection_expand_dl_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", "messages", NULL);
@@ -5271,12 +5152,16 @@ e_ews_connection_update_folder_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderChanges", "messages", NULL);
if (!create_cb (request, create_user_data, error)) {
- g_clear_obejct (&request);
+ g_clear_object (&request);
return FALSE;
}
@@ -5321,7 +5206,11 @@ e_ews_connection_move_folder_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "ToFolderId", "messages", NULL);
if (to_folder)
@@ -5432,7 +5321,11 @@ e_ews_connection_get_folder_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- TRUE);
+ TRUE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, folder_shape);
@@ -5474,10 +5367,10 @@ e_ews_connection_get_folder_sync (EEwsConnection *cnc,
}
static gboolean
-e_ews_process_create_folder_response (EEwsConnecton *cnc,
+e_ews_process_create_folder_response (EEwsConnection *cnc,
ESoapResponse *response,
EEwsFolderType folder_type,
- GSList *out_folder_ids, /* EwsFolderId * */
+ GSList **out_folder_ids, /* EwsFolderId * */
GError **error)
{
ESoapParameter *param;
@@ -5495,7 +5388,7 @@ e_ews_process_create_folder_response (EEwsConnecton *cnc,
if (local_error) {
g_propagate_error (error, local_error);
- return;
+ return FALSE;
}
subparam = e_soap_parameter_get_first_child (param);
@@ -5509,7 +5402,6 @@ e_ews_process_create_folder_response (EEwsConnecton *cnc,
if (E_EWS_CONNECTION_UTILS_CHECK_ELEMENT (name, "CreateFolderResponseMessage")) {
ESoapParameter *param, *node;
EwsFolderId *fid = NULL;
- GSList *fids = NULL;
const gchar *folder_element;
switch (folder_type) {
@@ -5535,7 +5427,7 @@ e_ews_process_create_folder_response (EEwsConnecton *cnc,
break;
}
- node = e_soap_parameter_get_first_child_by_name (soapparam, "Folders");
+ node = e_soap_parameter_get_first_child_by_name (subparam, "Folders");
node = e_soap_parameter_get_first_child_by_name (node, folder_element);
param = e_soap_parameter_get_first_child_by_name (node, "FolderId");
@@ -5579,7 +5471,11 @@ e_ews_connection_create_folder_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "ParentFolderId", "messages", NULL);
@@ -5694,7 +5590,8 @@ e_ews_connection_move_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
else
request = e_ews_request_new_with_header (
cnc->priv->uri,
@@ -5704,7 +5601,11 @@ e_ews_connection_move_items_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "ToFolderId", "messages", NULL);
e_soap_request_start_element (request, "FolderId", NULL, NULL);
@@ -5832,7 +5733,11 @@ e_ews_connection_delete_folder_sync (EEwsConnection *cnc,
delete_type,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderIds", "messages", NULL);
@@ -5876,7 +5781,7 @@ e_ews_connection_empty_folder_sync (EEwsConnection *cnc,
const gchar *folder_id,
gboolean is_distinguished_id,
const gchar *delete_type,
- gboolean delete_subfolder,
+ gboolean delete_subfolders,
GCancellable *cancellable,
GError **error)
{
@@ -5894,7 +5799,11 @@ e_ews_connection_empty_folder_sync (EEwsConnection *cnc,
delete_type,
cnc->priv->version,
E_EWS_EXCHANGE_2010,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_add_attribute (request, "DeleteSubFolders", delete_subfolders ? "true" : "false",
NULL, NULL);
@@ -6096,7 +6005,11 @@ e_ews_connection_create_attachments_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "ParentItemId", "messages", NULL);
e_soap_request_add_attribute (request, "Id", parent->id, NULL, NULL);
@@ -6109,7 +6022,7 @@ e_ews_connection_create_attachments_sync (EEwsConnection *cnc,
for (link = files; link; link = g_slist_next (link)) {
if (!e_ews_connection_attach_file (request, link->data, is_contact_photo, error)) {
- g_clear_obejct (&request);
+ g_clear_object (&request);
return FALSE;
}
}
@@ -6143,11 +6056,11 @@ e_ews_connection_create_attachments_sync (EEwsConnection *cnc,
}
}
- return ret;
+ return success;
}
static gboolean
-e_ews_process_delete_attachments_response (EEwsConnecton *cnc
+e_ews_process_delete_attachments_response (EEwsConnection *cnc,
ESoapResponse *response,
gchar **out_new_change_key,
GError **error)
@@ -6218,7 +6131,11 @@ e_ews_connection_delete_attachments_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
/* start interation over all items to get the attachemnts */
e_soap_request_start_element (request, "AttachmentIds", "messages", NULL);
@@ -6246,7 +6163,7 @@ e_ews_connection_delete_attachments_sync (EEwsConnection *cnc,
if (!success && out_new_change_key)
g_clear_pointer (out_new_change_key, g_free);
- return ret;
+ return success;
}
static gboolean
@@ -6299,14 +6216,10 @@ e_ews_process_get_attachments_response (EEwsConnection *cnc,
if (!g_ascii_strcasecmp (name, "ItemAttachment")) {
item = e_ews_item_new_from_soap_parameter (subattsparam);
- info = e_ews_item_dump_mime_content (item, async_data->directory);
+ info = e_ews_item_dump_mime_content (item, cache_directory);
g_clear_object (&item);
-
} else if (!g_ascii_strcasecmp (name, "FileAttachment")) {
- info = e_ews_dump_file_attachment_from_soap_parameter (
- subattsparam,
- cache_directory,
- uid);
+ info = e_ews_dump_file_attachment_from_soap_parameter (subattsparam,
cache_directory, uid);
}
if (info)
@@ -6353,14 +6266,18 @@ e_ews_connection_get_attachments_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
/* not sure why I need it, need to check */
if (progress_fn && progress_data)
e_soap_request_set_progress_fn (request, progress_fn, progress_data);
if (cache_directory)
- e_soap_request_store_node_data (request, "MimeContent Content", cache_directory, TRUE);
+ e_soap_request_set_store_node_data (request, "MimeContent Content", cache_directory, TRUE);
/* write empty attachments shape, need to discover maybe usefull in some cases */
e_soap_request_start_element (request, "AttachmentShape", "messages", NULL);
@@ -6526,7 +6443,7 @@ ews_handle_free_busy_view (ESoapParameter *param,
}
static gboolean
-e_ews_process_get_free_busy_response (EEwsConnection *cnc
+e_ews_process_get_free_busy_response (EEwsConnection *cnc,
ESoapResponse *response,
GSList **out_components,
GError **error)
@@ -6595,7 +6512,11 @@ e_ews_connection_get_free_busy_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
if (!free_busy_cb (request, free_busy_user_data, error)) {
g_clear_object (&request);
@@ -6834,7 +6755,11 @@ e_ews_connection_get_delegate_sync (EEwsConnection *cnc,
include_permissions ? "true" : "false",
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", "messages", NULL);
@@ -6873,7 +6798,7 @@ e_ews_process_update_delegate_response (EEwsConnection *cnc,
{
ESoapParameter *param;
ESoapParameter *subparam;
- GError *error = NULL;
+ GError *local_error = NULL;
if (ews_get_response_status (e_soap_response_get_parameter (response), &local_error)) {
param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", NULL);
@@ -6952,7 +6877,11 @@ e_ews_connection_add_delegate_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", "messages", NULL);
e_ews_request_write_string_parameter (request, "EmailAddress", NULL, mail_id ? mail_id :
cnc->priv->email);
@@ -7029,7 +6958,11 @@ e_ews_connection_remove_delegate_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", "messages", NULL);
e_ews_request_write_string_parameter (request, "EmailAddress", NULL, mail_id ? mail_id :
cnc->priv->email);
@@ -7038,14 +6971,14 @@ e_ews_connection_remove_delegate_sync (EEwsConnection *cnc,
e_soap_request_start_element (request, "UserIds", "messages", NULL);
for (link = delegate_ids; link; link = g_slist_next (link)) {
- const EwsUserId *user_id = iter->data;
+ const EwsUserId *user_id = link->data;
if (!user_id)
continue;
e_soap_request_start_element (request, "UserId", NULL, NULL);
e_ews_request_write_string_parameter (request, "PrimarySmtpAddress", NULL,
user_id->primary_smtp);
- e_soap_request_end_element (request); /* UserId */
+ e_soap_request_end_element (request);
}
e_soap_request_end_element (request); /* UserIds */
@@ -7091,7 +7024,11 @@ e_ews_connection_update_delegate_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", "messages", NULL);
e_ews_request_write_string_parameter (request, "EmailAddress", NULL, mail_id ? mail_id :
cnc->priv->email);
@@ -7234,7 +7171,11 @@ e_ews_connection_get_folder_permissions_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, "IdOnly");
@@ -7244,7 +7185,7 @@ e_ews_connection_get_folder_permissions_sync (EEwsConnection *cnc,
e_soap_request_end_element (request); /* FolderShape */
e_soap_request_start_element (request, "FolderIds", "messages", NULL);
- e_ews_folder_id_append_to_msg (request, cnc->priv->email, folder_id);
+ e_ews_folder_id_append_to_request (request, cnc->priv->email, folder_id);
e_soap_request_end_element (request);
e_ews_request_write_footer (request);
@@ -7295,7 +7236,11 @@ e_ews_connection_set_folder_permissions_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderChanges", "messages", NULL);
e_ews_request_start_folder_change (request, cnc->priv->email, folder_id);
@@ -7344,7 +7289,7 @@ e_ews_connection_set_folder_permissions_sync (EEwsConnection *cnc,
switch (perm->user_type) {
case E_EWS_PERMISSION_USER_TYPE_NONE:
- g_return_if_reached ();
+ g_warn_if_reached ();
break;
case E_EWS_PERMISSION_USER_TYPE_ANONYMOUS:
e_ews_request_write_string_parameter (request, "DistinguishedUser", NULL,
"Anonymous");
@@ -7473,7 +7418,11 @@ e_ews_connection_get_password_expiration_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2010_SP2,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_ews_request_write_string_parameter (request, "MailboxSmtpAddress", NULL, mail_id ? mail_id :
cnc->priv->email);
@@ -7570,7 +7519,11 @@ e_ews_connection_get_folder_info_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, "Default");
@@ -7581,7 +7534,7 @@ e_ews_connection_get_folder_info_sync (EEwsConnection *cnc,
e_soap_request_end_element (request); /* FolderShape */
e_soap_request_start_element (request, "FolderIds", "messages", NULL);
- e_ews_folder_id_append_to_msg (request, mail_id, folder_id);
+ e_ews_folder_id_append_to_request (request, mail_id, folder_id);
e_soap_request_end_element (request);
e_ews_request_write_footer (request);
@@ -7700,7 +7653,12 @@ e_ews_connection_find_folder_sync (EEwsConnection *cnc,
"Shallow",
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, "Default");
e_soap_request_start_element (request, "AdditionalProperties", NULL, NULL);
@@ -7807,7 +7765,7 @@ e_ews_connection_query_auth_methods_sync (EEwsConnection *cnc,
GInputStream *stream;
gulong cancelled_id = 0;
gboolean success;
- GError **local_error = NULL;
+ GError *local_error = NULL;
g_return_val_if_fail (cnc != NULL, FALSE);
g_return_val_if_fail (out_auth_methods != NULL, FALSE);
@@ -7823,7 +7781,11 @@ e_ews_connection_query_auth_methods_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- TRUE);
+ TRUE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "FolderShape", "messages", NULL);
e_ews_request_write_string_parameter (request, "BaseShape", NULL, "IdOnly");
@@ -7837,7 +7799,7 @@ e_ews_connection_query_auth_methods_sync (EEwsConnection *cnc,
session = e_ews_connection_create_soup_session (cnc);
- settings = e_ews_connecton_ref_settings (cnc);
+ settings = e_ews_connection_ref_settings (cnc);
message = e_soap_request_persist (request, session, settings, error);
g_clear_object (&settings);
@@ -7861,7 +7823,7 @@ e_ews_connection_query_auth_methods_sync (EEwsConnection *cnc,
/* The request should be cancelled in the got-headers handler */
g_clear_object (&stream);
- if (local_error && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERRRO_CANCELLED)) {
+ if (local_error && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
success = FALSE;
g_propagate_error (error, local_error);
g_slist_free_full (*out_auth_methods, g_free);
@@ -7880,7 +7842,7 @@ e_ews_connection_query_auth_methods_sync (EEwsConnection *cnc,
g_clear_object (&request);
if (success && g_cancellable_set_error_if_cancelled (cancellable, error)) {
- g_slist_free (*out_auth_methods, g_free);
+ g_slist_free_full (*out_auth_methods, g_free);
*out_auth_methods = NULL;
success = FALSE;
}
@@ -8682,7 +8644,11 @@ e_ews_connection_get_server_time_zones_sync (EEwsConnection *cnc,
"true",
cnc->priv->version,
E_EWS_EXCHANGE_2010,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Ids", "messages", NULL);
for (link = msdn_locations; link; link = g_slist_next (link)) {
@@ -8779,7 +8745,11 @@ e_ews_connection_get_user_photo_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2013,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Email", "messages", NULL);
e_soap_request_write_string (request, email);
@@ -8931,12 +8901,16 @@ e_ews_connection_get_user_configuration_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2010,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "UserConfigurationName", "messages", NULL);
e_soap_request_add_attribute (request, "Name", config_name, NULL, NULL);
- e_ews_folder_id_append_to_msg (request, cnc->priv->email, &local_fid);
+ e_ews_folder_id_append_to_request (request, cnc->priv->email, &local_fid);
e_soap_request_end_element (request); /* UserConfigurationName */
@@ -9064,7 +9038,11 @@ e_ews_connection_convert_id_sync (EEwsConnection *cnc,
to_format,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "SourceIds", "messages", NULL);
e_soap_request_start_element (request, "AlternateId", NULL, NULL);
@@ -9191,21 +9169,21 @@ e_ews_process_get_user_oof_settings_response (EEwsConnection *cnc,
subparam = e_soap_parameter_get_first_child_by_name (param, "OofState");
string = e_soap_parameter_get_string_value (subparam);
if (g_strcmp0 (string, "Disabled") == 0)
- e_ews_oof_settings_set_state (settings, E_EWS_OOF_STATE_DISABLED);
+ e_ews_oof_settings_set_state (oof_settings, E_EWS_OOF_STATE_DISABLED);
else if (g_strcmp0 (string, "Enabled") == 0)
- e_ews_oof_settings_set_state (settings, E_EWS_OOF_STATE_ENABLED);
+ e_ews_oof_settings_set_state (oof_settings, E_EWS_OOF_STATE_ENABLED);
else if (g_strcmp0 (string, "Scheduled") == 0)
- e_ews_oof_settings_set_state (settings, E_EWS_OOF_STATE_SCHEDULED);
+ e_ews_oof_settings_set_state (oof_settings, E_EWS_OOF_STATE_SCHEDULED);
g_free (string);
subparam = e_soap_parameter_get_first_child_by_name (param, "ExternalAudience");
string = e_soap_parameter_get_string_value (subparam);
if (g_strcmp0 (string, "None") == 0)
- e_ews_oof_settings_set_external_audience (settings, E_EWS_EXTERNAL_AUDIENCE_NONE);
+ e_ews_oof_settings_set_external_audience (oof_settings, E_EWS_EXTERNAL_AUDIENCE_NONE);
else if (g_strcmp0 (string, "Known") == 0)
- e_ews_oof_settings_set_external_audience (settings, E_EWS_EXTERNAL_AUDIENCE_KNOWN);
+ e_ews_oof_settings_set_external_audience (oof_settings, E_EWS_EXTERNAL_AUDIENCE_KNOWN);
else if (g_strcmp0 (string, "All") == 0)
- e_ews_oof_settings_set_external_audience (settings, E_EWS_EXTERNAL_AUDIENCE_ALL);
+ e_ews_oof_settings_set_external_audience (oof_settings, E_EWS_EXTERNAL_AUDIENCE_ALL);
g_free (string);
subparam = e_soap_parameter_get_first_child_by_name (param, "Duration");
@@ -9213,7 +9191,7 @@ e_ews_process_get_user_oof_settings_response (EEwsConnection *cnc,
string = e_soap_parameter_get_string_value (subsubparam);
date_time = ews_oof_settings_string_to_date_time (string);
if (date_time != NULL) {
- e_ews_oof_settings_set_start_time (settings, date_time);
+ e_ews_oof_settings_set_start_time (oof_settings, date_time);
g_date_time_unref (date_time);
}
g_free (string);
@@ -9222,7 +9200,7 @@ e_ews_process_get_user_oof_settings_response (EEwsConnection *cnc,
string = e_soap_parameter_get_string_value (subsubparam);
date_time = ews_oof_settings_string_to_date_time (string);
if (date_time != NULL) {
- e_ews_oof_settings_set_end_time (settings, date_time);
+ e_ews_oof_settings_set_end_time (oof_settings, date_time);
g_date_time_unref (date_time);
}
g_free (string);
@@ -9238,7 +9216,7 @@ e_ews_process_get_user_oof_settings_response (EEwsConnection *cnc,
text = ews_oof_settings_text_from_html (string);
else
text = g_strdup (string);
- e_ews_oof_settings_set_internal_reply (settings, text ? text : "");
+ e_ews_oof_settings_set_internal_reply (oof_settings, text ? text : "");
g_free (string);
g_free (text);
@@ -9253,7 +9231,7 @@ e_ews_process_get_user_oof_settings_response (EEwsConnection *cnc,
text = ews_oof_settings_text_from_html (string);
else
text = g_strdup (string);
- e_ews_oof_settings_set_external_reply (settings, text ? text : "");
+ e_ews_oof_settings_set_external_reply (oof_settings, text ? text : "");
g_free (string);
g_free (text);
@@ -9265,7 +9243,7 @@ e_ews_connection_get_user_oof_settings_sync (EEwsConnection *cnc,
gint pri,
EEwsOofSettings *inout_oof_settings,
GCancellable *cancellable,
- GError **error);
+ GError **error)
{
ESoapRequest *request;
ESoapResponse *response;
@@ -9282,7 +9260,11 @@ e_ews_connection_get_user_oof_settings_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", NULL, NULL);
e_ews_request_write_string_parameter (request, "Address", NULL, e_ews_connection_get_mailbox (cnc));
@@ -9297,24 +9279,21 @@ e_ews_connection_get_user_oof_settings_sync (EEwsConnection *cnc,
return FALSE;
}
- success = e_ews_process_get_user_oof_settings_response (cnc, response, out_converted_id, error);
+ success = e_ews_process_get_user_oof_settings_response (cnc, response, inout_oof_settings, error);
g_clear_object (&request);
g_clear_object (&response);
- if (!success)
- g_clear_pointer (out_converted_id, g_free);
-
return success;
}
static gchar *
-ews_oof_settings_date_time_to_string (GDateTime *date_time)
+ews_oof_settings_date_time_to_string (const GDateTime *date_time)
{
gchar *string = NULL;
if (date_time)
- string = g_date_time_format_iso8601 (date_time);
+ string = g_date_time_format_iso8601 ((GDateTime *) date_time);
return string;
}
@@ -9329,12 +9308,13 @@ e_ews_connection_set_user_oof_settings_sync (EEwsConnection *cnc,
const gchar *internal_reply,
const gchar *external_reply,
GCancellable *cancellable,
- GError **error);
+ GError **error)
{
ESoapRequest *request;
ESoapResponse *response;
gchar *start_time;
gchar *end_time;
+ const gchar *string;
gboolean success;
g_return_val_if_fail (cnc != NULL, FALSE);
@@ -9347,7 +9327,11 @@ e_ews_connection_set_user_oof_settings_sync (EEwsConnection *cnc,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
- FALSE);
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
e_soap_request_start_element (request, "Mailbox", NULL, NULL);
e_ews_request_write_string_parameter (request, "Address", NULL, e_ews_connection_get_mailbox (cnc));
@@ -9426,3 +9410,237 @@ e_ews_connection_set_user_oof_settings_sync (EEwsConnection *cnc,
return success;
}
+
+static gboolean
+e_ews_process_subscribe_response (EEwsConnection *cnc,
+ ESoapResponse *response,
+ gchar **out_subscription_id,
+ GError **error)
+{
+ ESoapParameter *param, *subparam;
+ GError *local_error = NULL;
+
+ param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &local_error);
+
+ /* Sanity check */
+ g_return_val_if_fail (
+ (param != NULL && local_error == NULL) ||
+ (param == NULL && local_error != NULL), FALSE);
+
+ if (local_error) {
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ subparam = e_soap_parameter_get_first_child (param);
+
+ while (subparam != NULL) {
+ const gchar *name = (const gchar *) subparam->name;
+
+ if (!ews_get_response_status (subparam, error))
+ return FALSE;
+
+ if (E_EWS_CONNECTION_UTILS_CHECK_ELEMENT (name, "SubscribeResponseMessage")) {
+ ESoapParameter *node;
+
+ node = e_soap_parameter_get_first_child_by_name (subparam, "SubscriptionId");
+ *out_subscription_id = e_soap_parameter_get_string_value (node);
+
+ break;
+ }
+
+ subparam = e_soap_parameter_get_next_child (subparam);
+ }
+
+ return *out_subscription_id != NULL;
+}
+
+gboolean
+e_ews_connection_subscribe_sync (EEwsConnection *cnc,
+ gint pri,
+ const GSList *folder_ids, /* gchar * */
+ gchar **out_subscription_id,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ESoapRequest *request;
+ ESoapResponse *response;
+ const GSList *link;
+ const gchar * const *event_names;
+ gint event_type;
+ gboolean success;
+
+ g_return_val_if_fail (cnc != NULL, FALSE);
+ g_return_val_if_fail (out_subscription_id != NULL, FALSE);
+
+ *out_subscription_id = NULL;
+
+ request = e_ews_request_new_with_header (
+ cnc->priv->uri,
+ cnc->priv->impersonate_user,
+ "Subscribe",
+ NULL,
+ NULL,
+ cnc->priv->version,
+ E_EWS_EXCHANGE_2010_SP1,
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
+ e_soap_request_start_element (request, "StreamingSubscriptionRequest", "messages", NULL);
+
+ e_soap_request_start_element (request, "FolderIds", NULL, NULL);
+ for (link = folder_ids; link; link = g_slist_next (link)) {
+ e_ews_request_write_string_parameter_with_attribute (request, "FolderId", NULL, NULL, "Id",
link->data);
+ }
+ e_soap_request_end_element (request); /* FolderIds */
+
+ event_names = e_ews_notification_get_event_names ();
+
+ e_soap_request_start_element (request, "EventTypes", NULL, NULL);
+ for (event_type = 0; event_names[event_type] != NULL; event_type++) {
+ if (g_strcmp0 (event_names[event_type], "StatusEvent") == 0)
+ continue;
+
+ e_ews_request_write_string_parameter_with_attribute (request, "EventType", NULL,
event_names[event_type], NULL, NULL);
+ }
+ e_soap_request_end_element (request); /* EventTypes */
+
+ e_soap_request_end_element (request); /* StreamingSubscriptionRequest */
+
+ e_ews_request_write_footer (request);
+
+ response = e_ews_connection_send_request_sync (cnc, request, cancellable, error);
+
+ if (!response) {
+ g_clear_object (&request);
+ return FALSE;
+ }
+
+ success = e_ews_process_subscribe_response (cnc, response, out_subscription_id, error);
+
+ g_clear_object (&request);
+ g_clear_object (&response);
+
+ return success;
+}
+
+gboolean
+e_ews_connection_unsubscribe_sync (EEwsConnection *cnc,
+ gint pri,
+ const gchar *subscription_id,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ESoapRequest *request;
+ ESoapResponse *response;
+ gboolean success;
+
+ g_return_val_if_fail (cnc != NULL, FALSE);
+ g_return_val_if_fail (subscription_id != NULL, FALSE);
+
+ request = e_ews_request_new_with_header (
+ cnc->priv->uri,
+ cnc->priv->impersonate_user,
+ "Unsubscribe",
+ NULL,
+ NULL,
+ cnc->priv->version,
+ E_EWS_EXCHANGE_2010_SP1,
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
+ e_ews_request_write_string_parameter_with_attribute (request, "SubscriptionId", "messages",
subscription_id, NULL, NULL);
+
+ e_ews_request_write_footer (request);
+
+ response = e_ews_connection_send_request_sync (cnc, request, cancellable, error);
+
+ if (!response) {
+ g_clear_object (&request);
+ return FALSE;
+ }
+
+ success = e_ews_process_generic_response (cnc, response, error);
+
+ g_clear_object (&request);
+ g_clear_object (&response);
+
+ return success;
+}
+
+static void
+e_ews_get_streaming_events_custom_process (ESoapRequest *request,
+ SoupMessage *message,
+ GInputStream *input_stream,
+ gpointer user_data,
+ gboolean *out_repeat,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GInputStream **out_input_stream = user_data;
+
+ if (out_input_stream && input_stream)
+ *out_input_stream = g_object_ref (input_stream);
+}
+
+gboolean
+e_ews_connection_get_streaming_events_sync (EEwsConnection *cnc,
+ gint pri,
+ const gchar *subscription_id,
+ GInputStream **out_input_stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ESoapRequest *request;
+ ESoapResponse *response;
+ GInputStream *input_stream = NULL;
+ gboolean success;
+
+ g_return_val_if_fail (cnc != NULL, FALSE);
+ g_return_val_if_fail (subscription_id != NULL, FALSE);
+
+ request = e_ews_request_new_with_header (
+ cnc->priv->uri,
+ cnc->priv->impersonate_user,
+ "GetStreamingEvents",
+ NULL,
+ NULL,
+ cnc->priv->version,
+ E_EWS_EXCHANGE_2010_SP1,
+ FALSE,
+ error);
+
+ if (!request)
+ return FALSE;
+
+ e_soap_request_start_element (request, "SubscriptionIds", "messages", NULL);
+ e_ews_request_write_string_parameter_with_attribute (request, "SubscriptionId", NULL,
subscription_id, NULL, NULL);
+ e_soap_request_end_element (request);
+
+ e_ews_request_write_string_parameter_with_attribute (request, "ConnectionTimeout", "messages", "10",
NULL, NULL);
+
+ e_ews_request_write_footer (request);
+
+ e_soap_request_set_custom_process_fn (request, e_ews_get_streaming_events_custom_process,
&input_stream);
+
+ response = e_ews_connection_send_request_sync (cnc, request, cancellable, error);
+ g_warn_if_fail (response == NULL);
+
+ g_clear_object (&request);
+ g_clear_object (&response);
+
+ success = input_stream != NULL;
+
+ if (success && out_input_stream)
+ *out_input_stream = input_stream;
+ else
+ g_clear_object (&input_stream);
+
+ return success;
+}
diff --git a/src/EWS/common/e-ews-connection.h b/src/EWS/common/e-ews-connection.h
index 7380e046..09ee1315 100644
--- a/src/EWS/common/e-ews-connection.h
+++ b/src/EWS/common/e-ews-connection.h
@@ -425,10 +425,6 @@ gboolean e_ews_connection_get_ssl_error_details
gchar **out_certificate_pem,
GTlsCertificateFlags *out_certificate_errors);
const gchar * e_ews_connection_get_uri (EEwsConnection *cnc);
-ESoupAuthBearer *
- e_ews_connection_ref_bearer_auth(EEwsConnection *cnc);
-void e_ews_connection_set_bearer_auth(EEwsConnection *cnc,
- ESoupAuthBearer *bearer_auth);
const gchar * e_ews_connection_get_password (EEwsConnection *cnc);
gchar * e_ews_connection_dup_password (EEwsConnection *cnc);
void e_ews_connection_set_password (EEwsConnection *cnc,
@@ -443,8 +439,6 @@ void e_ews_connection_set_proxy_resolver
GProxyResolver *proxy_resolver);
CamelEwsSettings *
e_ews_connection_ref_settings (EEwsConnection *cnc);
-SoupSession * e_ews_connection_ref_soup_session
- (EEwsConnection *cnc);
gboolean e_ews_connection_get_backoff_enabled
(EEwsConnection *cnc);
void e_ews_connection_set_backoff_enabled
@@ -887,6 +881,26 @@ gboolean e_ews_connection_set_user_oof_settings_sync
const gchar *external_reply,
GCancellable *cancellable,
GError **error);
+gboolean e_ews_connection_subscribe_sync (EEwsConnection *cnc,
+ gint pri,
+ const GSList *folder_ids, /* gchar * */
+ gchar **out_subscription_id,
+ GCancellable *cancellable,
+ GError **error);
+gboolean e_ews_connection_unsubscribe_sync
+ (EEwsConnection *cnc,
+ gint pri,
+ const gchar *subscription_id,
+ GCancellable *cancellable,
+ GError **error);
+gboolean e_ews_connection_get_streaming_events_sync
+ (EEwsConnection *cnc,
+ gint pri,
+ const gchar *subscription_id,
+ GInputStream **out_input_stream,
+ GCancellable *cancellable,
+ GError **error);
+
G_END_DECLS
#endif
diff --git a/src/EWS/common/e-ews-folder.c b/src/EWS/common/e-ews-folder.c
index 33c3f6bc..fc07ee96 100644
--- a/src/EWS/common/e-ews-folder.c
+++ b/src/EWS/common/e-ews-folder.c
@@ -363,11 +363,11 @@ e_ews_folder_id_is_equal (const EwsFolderId *a,
}
void
-e_ews_folder_id_append_to_msg (ESoapRequest *request,
- const gchar *email,
- const EwsFolderId *fid)
+e_ews_folder_id_append_to_request (ESoapRequest *request,
+ const gchar *email,
+ const EwsFolderId *fid)
{
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (fid != NULL);
if (fid->is_distinguished_id)
@@ -382,10 +382,10 @@ e_ews_folder_id_append_to_msg (ESoapRequest *request,
if (fid->is_distinguished_id && email) {
e_soap_request_start_element (request, "Mailbox", NULL, NULL);
e_ews_request_write_string_parameter (request, "EmailAddress", NULL, email);
- e_soap_request_end_element (msg);
+ e_soap_request_end_element (request);
}
- e_soap_request_end_element (msg);
+ e_soap_request_end_element (request);
}
const gchar *
diff --git a/src/EWS/common/e-ews-folder.h b/src/EWS/common/e-ews-folder.h
index d89267f8..ee6c1628 100644
--- a/src/EWS/common/e-ews-folder.h
+++ b/src/EWS/common/e-ews-folder.h
@@ -76,9 +76,9 @@ void e_ews_folder_id_free (EwsFolderId *fid);
gboolean e_ews_folder_id_is_equal (const EwsFolderId *a,
const EwsFolderId *b,
gboolean check_change_key);
-void e_ews_folder_id_append_to_msg (ESoapRequest *request,
- const gchar *email,
- const EwsFolderId *fid);
+void e_ews_folder_id_append_to_request (ESoapRequest *request,
+ const gchar *email,
+ const EwsFolderId *fid);
gchar * e_ews_folder_utils_escape_name (const gchar *folder_name);
gchar * e_ews_folder_utils_unescape_name (const gchar *escaped_folder_name);
diff --git a/src/EWS/common/e-ews-item-change.c b/src/EWS/common/e-ews-item-change.c
index 6cee0d31..5389228f 100644
--- a/src/EWS/common/e-ews-item-change.c
+++ b/src/EWS/common/e-ews-item-change.c
@@ -17,11 +17,11 @@ e_ews_request_start_folder_change (ESoapRequest *request,
const gchar *email,
const EwsFolderId *folder_id)
{
- g_return_if_fail (msg != NULL);
+ g_return_if_fail (request != NULL);
g_return_if_fail (folder_id != NULL);
e_soap_request_start_element (request, "FolderChange", NULL, NULL);
- e_ews_folder_id_append_to_msg (request, email, folder_id);
+ e_ews_folder_id_append_to_request (request, email, folder_id);
e_soap_request_start_element (request, "Updates", NULL, NULL);
}
@@ -37,54 +37,34 @@ e_ews_request_start_item_change (ESoapRequest *request,
switch (type) {
case E_EWS_ITEMCHANGE_TYPE_FOLDER:
e_soap_request_start_element (request, "FolderChange", NULL, NULL);
- e_soap_request_start_element (
- msg, "FolderId",
- NULL, NULL);
- e_soap_request_add_attribute (
- msg, "Id",
- itemid, NULL, NULL);
+ e_soap_request_start_element (request, "FolderId", NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", itemid, NULL, NULL);
break;
case E_EWS_ITEMCHANGE_TYPE_ITEM:
e_soap_request_start_element (request, "ItemChange", NULL, NULL);
- e_soap_request_start_element (
- msg, "ItemId",
- NULL, NULL);
- e_soap_request_add_attribute (
- msg, "Id",
- itemid, NULL, NULL);
+ e_soap_request_start_element (request, "ItemId", NULL, NULL);
+ e_soap_request_add_attribute (request, "Id", itemid, NULL, NULL);
break;
case E_EWS_ITEMCHANGE_TYPE_OCCURRENCEITEM:
e_soap_request_start_element (request, "ItemChange", NULL, NULL);
- e_soap_request_start_element (
- msg, "OccurrenceItemId",
- NULL, NULL);
- e_soap_request_add_attribute (
- msg, "RecurringMasterId",
- itemid, NULL, NULL);
+ e_soap_request_start_element (request, "OccurrenceItemId", NULL, NULL);
+ e_soap_request_add_attribute (request, "RecurringMasterId", itemid, NULL, NULL);
instance = g_strdup_printf ("%d", instance_index);
- e_soap_request_add_attribute (
- msg, "InstanceIndex", instance,
- NULL, NULL);
+ e_soap_request_add_attribute (request, "InstanceIndex", instance, NULL, NULL);
g_free (instance);
break;
case E_EWS_ITEMCHANGE_TYPE_RECURRINGMASTER:
e_soap_request_start_element (request, "ItemChange", NULL, NULL);
- e_soap_request_start_element (
- msg, "RecurringMasterItemId",
- NULL, NULL);
- e_soap_request_add_attribute (
- msg, "OccurrenceId",
- itemid, NULL, NULL);
+ e_soap_request_start_element (request, "RecurringMasterItemId", NULL, NULL);
+ e_soap_request_add_attribute (request, "OccurrenceId", itemid, NULL, NULL);
break;
}
if (changekey)
- e_soap_request_add_attribute (
- msg, "ChangeKey",
- changekey, NULL, NULL);
- e_soap_request_end_element (msg);
+ e_soap_request_add_attribute (request, "ChangeKey", changekey, NULL, NULL);
+ e_soap_request_end_element (request);
e_soap_request_start_element (request, "Updates", NULL, NULL);
}
@@ -92,8 +72,8 @@ e_ews_request_start_item_change (ESoapRequest *request,
void
e_ews_request_end_item_change (ESoapRequest *request)
{
- e_soap_request_end_element (msg); /* Updates */
- e_soap_request_end_element (msg); /* ItemChange */
+ e_soap_request_end_element (request); /* Updates */
+ e_soap_request_end_element (request); /* ItemChange */
}
void
@@ -106,8 +86,7 @@ e_ews_request_start_set_item_field (ESoapRequest *request,
fielduri = g_strconcat (fielduri_prefix, ":", name, NULL);
e_soap_request_start_element (request, "SetItemField", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg, "FieldURI", NULL, NULL, "FieldURI", fielduri);
+ e_ews_request_write_string_parameter_with_attribute (request, "FieldURI", NULL, NULL, "FieldURI",
fielduri);
e_soap_request_start_element (request, field_kind, NULL, NULL);
g_free (fielduri);
@@ -132,7 +111,7 @@ e_ews_request_start_set_indexed_item_field (ESoapRequest *request,
e_soap_request_start_element (request, "IndexedFieldURI", NULL, NULL);
e_soap_request_add_attribute (request, "FieldURI", fielduri, NULL, NULL);
e_soap_request_add_attribute (request, "FieldIndex", field_index, NULL, NULL);
- e_soap_request_end_element (msg);
+ e_soap_request_end_element (request);
if (!delete_field)
e_soap_request_start_element (request, field_kind, NULL, NULL);
@@ -145,15 +124,15 @@ e_ews_request_end_set_indexed_item_field (ESoapRequest *request,
gboolean delete_field)
{
if (!delete_field)
- e_soap_request_end_element (msg); /* CalendarItem */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* CalendarItem */
+ e_soap_request_end_element (request); /* SetItemField */
}
void
e_ews_request_end_set_item_field (ESoapRequest *request)
{
- e_soap_request_end_element (msg); /* CalendarItem */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* CalendarItem */
+ e_soap_request_end_element (request); /* SetItemField */
}
void
@@ -166,9 +145,8 @@ e_ews_request_add_delete_item_field (ESoapRequest *request,
fielduri = g_strconcat (fielduri_prefix, ":", name, NULL);
e_soap_request_start_element (request, "DeleteItemField", NULL, NULL);
- e_ews_request_write_string_parameter_with_attribute (
- msg, "FieldURI", NULL, NULL, "FieldURI", fielduri);
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_ews_request_write_string_parameter_with_attribute (request, "FieldURI", NULL, NULL, "FieldURI",
fielduri);
+ e_soap_request_end_element (request); /* DeleteItemField */
g_free (fielduri);
}
@@ -187,8 +165,8 @@ e_ews_request_add_delete_item_field_indexed (ESoapRequest *request,
e_soap_request_start_element (request, "IndexedFieldURI", NULL, NULL);
e_soap_request_add_attribute (request, "FieldURI", fielduri, NULL, NULL);
e_soap_request_add_attribute (request, "FieldIndex", field_index, NULL, NULL);
- e_soap_request_end_element (msg); /* IndexedFieldURI */
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_soap_request_end_element (request); /* IndexedFieldURI */
+ e_soap_request_end_element (request); /* DeleteItemField */
g_free (fielduri);
}
@@ -225,7 +203,7 @@ e_ews_request_add_delete_item_field_extended_tag (ESoapRequest *request,
e_soap_request_start_element (request, "DeleteItemField", NULL, NULL);
e_ews_request_write_extended_tag (request, prop_id, prop_type);
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_soap_request_end_element (request); /* DeleteItemField */
}
void
@@ -240,7 +218,7 @@ e_ews_request_add_delete_item_field_extended_distinguished_tag (ESoapRequest *re
e_soap_request_start_element (request, "DeleteItemField", NULL, NULL);
e_ews_request_write_extended_distinguished_tag (request, set_id, prop_id, prop_type);
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_soap_request_end_element (request); /* DeleteItemField */
}
static void
@@ -286,7 +264,7 @@ ews_request_add_extended_property_tag (ESoapRequest *request,
e_ews_request_write_extended_tag (request, prop_id, prop_type);
ews_request_write_data_value (request, data_type, value);
- e_soap_request_end_element (msg); /* ExtendedProperty */
+ e_soap_request_end_element (request); /* ExtendedProperty */
}
static void
@@ -305,7 +283,7 @@ ews_request_add_extended_property_distinguished_tag (ESoapRequest *request,
e_ews_request_write_extended_distinguished_tag (request, set_id, prop_id, prop_type);
ews_request_write_data_value (request, data_type, value);
- e_soap_request_end_element (msg); /* ExtendedProperty */
+ e_soap_request_end_element (request); /* ExtendedProperty */
}
static void
@@ -325,9 +303,9 @@ ews_request_add_set_item_field_extended_tag (ESoapRequest *request,
e_soap_request_start_element (request, elem_name, elem_prefix, NULL);
ews_request_add_extended_property_tag (request, prop_id, data_type, value);
- e_soap_request_end_element (msg); /* elem_name */
+ e_soap_request_end_element (request); /* elem_name */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* SetItemField */
}
static void
@@ -349,9 +327,9 @@ ews_request_add_set_item_field_extended_distinguished_tag (ESoapRequest *request
e_soap_request_start_element (request, elem_name, elem_prefix, NULL);
ews_request_add_extended_property_distinguished_tag (request, set_id, prop_id, data_type, value);
- e_soap_request_end_element (msg); /* elem_name */
+ e_soap_request_end_element (request); /* elem_name */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* SetItemField */
}
void
@@ -575,7 +553,7 @@ e_ews_request_add_delete_item_field_extended_name (ESoapRequest *request,
e_soap_request_start_element (request, "DeleteItemField", NULL, NULL);
e_ews_request_write_extended_name (request, name, prop_type);
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_soap_request_end_element (request); /* DeleteItemField */
}
void
@@ -590,7 +568,7 @@ e_ews_request_add_delete_item_field_extended_distinguished_name (ESoapRequest *r
e_soap_request_start_element (request, "DeleteItemField", NULL, NULL);
e_ews_request_write_extended_distinguished_name (request, set_id, name, prop_type);
- e_soap_request_end_element (msg); /* DeleteItemField */
+ e_soap_request_end_element (request); /* DeleteItemField */
}
static void
@@ -608,7 +586,7 @@ ews_request_add_extended_property_name (ESoapRequest *request,
e_ews_request_write_extended_name (request, name, prop_type);
ews_request_write_data_value (request, data_type, value);
- e_soap_request_end_element (msg); /* ExtendedProperty */
+ e_soap_request_end_element (request); /* ExtendedProperty */
}
static void
@@ -627,7 +605,7 @@ ews_request_add_extended_property_distinguished_name (ESoapRequest *request,
e_ews_request_write_extended_distinguished_name (request, set_id, name, prop_type);
ews_request_write_data_value (request, data_type, value);
- e_soap_request_end_element (msg); /* ExtendedProperty */
+ e_soap_request_end_element (request); /* ExtendedProperty */
}
static void
@@ -647,9 +625,9 @@ ews_request_add_set_item_field_extended_name (ESoapRequest *request,
e_soap_request_start_element (request, elem_name, elem_prefix, NULL);
ews_request_add_extended_property_name (request, name, data_type, value);
- e_soap_request_end_element (msg); /* elem_name */
+ e_soap_request_end_element (request); /* elem_name */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* SetItemField */
}
static void
@@ -671,9 +649,9 @@ ews_request_add_set_item_field_extended_distinguished_name (ESoapRequest *reques
e_soap_request_start_element (request, elem_name, elem_prefix, NULL);
ews_request_add_extended_property_distinguished_name (request, set_id, name, data_type, value);
- e_soap_request_end_element (msg); /* elem_name */
+ e_soap_request_end_element (request); /* elem_name */
- e_soap_request_end_element (msg); /* SetItemField */
+ e_soap_request_end_element (request); /* SetItemField */
}
void
diff --git a/src/EWS/common/e-ews-item.c b/src/EWS/common/e-ews-item.c
index 9705523f..6d3d4af9 100644
--- a/src/EWS/common/e-ews-item.c
+++ b/src/EWS/common/e-ews-item.c
@@ -14,7 +14,7 @@
#include <glib.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>
-#include <libsoup/soup-misc.h>
+#include <libsoup/soup.h>
#include <libedataserver/libedataserver.h>
#include <libecal/libecal.h>
diff --git a/src/EWS/common/e-ews-notification.c b/src/EWS/common/e-ews-notification.c
index 143e8f51..ed95cdad 100644
--- a/src/EWS/common/e-ews-notification.c
+++ b/src/EWS/common/e-ews-notification.c
@@ -11,13 +11,11 @@
#include "e-ews-connection-utils.h"
#include "e-ews-debug.h"
#include "e-ews-notification.h"
-#include "e-soup-auth-negotiate.h"
struct _EEwsNotificationPrivate {
GMutex thread_lock;
SoupSession *soup_session;
GWeakRef connection_wk;
- GByteArray *chunk;
GCancellable *cancellable;
gchar *last_subscription_id; /* guarded by the caller, because it can be set only after construct */
};
@@ -46,6 +44,12 @@ static const gchar *default_events_names[] = {
NULL
};
+const gchar * const *
+e_ews_notification_get_event_names (void)
+{
+ return (const gchar * const *) default_events_names;
+}
+
typedef struct _EEwsNotificationThreadData EEwsNotificationThreadData;
struct _EEwsNotificationThreadData {
@@ -63,25 +67,6 @@ e_ews_notification_ref_connection (const EEwsNotification *notification)
return g_weak_ref_get (¬ification->priv->connection_wk);
}
-static gboolean
-ews_notification_authenticate (SoupMessage *message,
- SoupAuth *auth,
- gboolean retrying,
- gpointer data)
-{
- EEwsNotification *notification = data;
- EEwsConnection *cnc;
-
- g_return_if_fail (notification != NULL);
-
- cnc = e_ews_notification_ref_connection (notification);
-
- if (cnc) {
- e_ews_connection_utils_authenticate (cnc, notif->priv->soup_session, message, auth, retrying);
- g_clear_object (&cnc);
- }
-}
-
EEwsNotification *
e_ews_notification_new (EEwsConnection *connection,
gchar *last_subscription_id)
@@ -260,19 +245,12 @@ e_ews_notification_init (EEwsNotification *notification)
static gboolean
e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
- GSList *folders,
- gchar **subscription_id,
+ GSList *folder_ids, /* gchar * */
+ gchar **out_subscription_id,
GCancellable *cancellable)
{
EEwsConnection *cnc;
- ESoapRequest *request;
- ESoapResponse *response;
- ESoapParameter *param, *subparam;
- CamelEwsSettings *settings;
- GError *error = NULL;
- GSList *l;
- guint event_type;
- xmlDoc *doc;
+ gboolean success;
g_return_val_if_fail (notification != NULL, FALSE);
g_return_val_if_fail (notification->priv != NULL, FALSE);
@@ -286,145 +264,22 @@ e_ews_notification_subscribe_folder_sync (EEwsNotification *notification,
if (!cnc)
return FALSE;
- settings = e_ews_connection_ref_settings (cnc);
-
- msg = e_ews_request_new_with_header (
- settings,
- e_ews_connection_get_uri (cnc),
- e_ews_connection_get_impersonate_user (cnc),
- "Subscribe",
- NULL,
- NULL,
- e_ews_connection_get_server_version (cnc),
- E_EWS_EXCHANGE_2010_SP1,
- FALSE,
- FALSE);
-
- g_clear_object (&settings);
-
- if (!msg) {
- g_warning ("%s: Failed to create Soup message for URI '%s'", G_STRFUNC,
e_ews_connection_get_uri (cnc));
- g_object_unref (cnc);
- return FALSE;
- }
-
- e_soap_request_start_element (msg, "StreamingSubscriptionRequest", "messages", NULL);
-
- e_soap_request_start_element (msg, "FolderIds", NULL, NULL);
- for (l = folders; l; l = l->next) {
- e_ews_request_write_string_parameter_with_attribute (
- msg,
- "FolderId",
- NULL,
- NULL,
- "Id",
- l->data);
- }
- e_soap_request_end_element (msg); /* FolderIds */
-
- e_soap_request_start_element (msg, "EventTypes", NULL, NULL);
- for (event_type = 0; default_events_names[event_type] != NULL; event_type++) {
- if (g_strcmp0 (default_events_names[event_type], "StatusEvent") == 0)
- continue;
-
- e_ews_request_write_string_parameter_with_attribute (
- msg,
- "EventType",
- NULL,
- default_events_names[event_type],
- NULL,
- NULL);
- }
- e_soap_request_end_element (msg); /* EventTypes */
-
- e_soap_request_end_element (msg); /* StreamingSubscriptionRequest */
- e_ews_request_write_footer (msg); /* Complete the footer and print the request */
-
- if (g_cancellable_is_cancelled (cancellable)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
- }
-
- if (!e_ews_connection_utils_prepare_message (cnc, notification->priv->soup_session, SOUP_MESSAGE
(msg), cancellable)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
- }
-
- g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
-
- soup_session_send_message (notification->priv->soup_session, SOUP_MESSAGE (msg));
- if (!SOUP_STATUS_IS_SUCCESSFUL (SOUP_MESSAGE (msg)->status_code)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
- }
-
- doc = xmlReadMemory (
- SOUP_MESSAGE (msg)->response_body->data,
- SOUP_MESSAGE (msg)->response_body->length,
- "response.xml", NULL, 0);
+ success = e_ews_connection_subscribe_sync (cnc, G_PRIORITY_DEFAULT, folder_ids, out_subscription_id,
cancellable, NULL);
- response = e_soap_response_new_from_xmldoc (doc);
+ g_signal_emit (notification, signals[SUBSCRIPTION_ID_CHANGED], 0, success ? *out_subscription_id :
NULL, NULL);
- g_object_unref (msg);
g_object_unref (cnc);
- param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &error);
-
- /* Sanity check */
- g_warn_if_fail ((param != NULL && error == NULL) || (param == NULL && error != NULL));
-
- if (error != NULL) {
- g_warning (G_STRLOC ": %s\n", error->message);
- g_error_free (error);
-
- g_object_unref (response);
- return FALSE;
- }
-
- subparam = e_soap_parameter_get_first_child (param);
-
- while (subparam != NULL) {
- const gchar *name = (const gchar *) subparam->name;
-
- if (!ews_get_response_status (subparam, &error)) {
- g_warning (G_STRLOC ": %s\n", error->message);
- g_error_free (error);
-
- g_object_unref (response);
- return FALSE;
- }
-
- if (E_EWS_CONNECTION_UTILS_CHECK_ELEMENT (name, "SubscribeResponseMessage")) {
- ESoapParameter *node;
-
- node = e_soap_parameter_get_first_child_by_name (subparam, "SubscriptionId");
- *subscription_id = e_soap_parameter_get_string_value (node);
- }
-
- subparam = e_soap_parameter_get_next_child (subparam);
- }
-
- g_object_unref (response);
-
- g_signal_emit (notification, signals[SUBSCRIPTION_ID_CHANGED], 0, *subscription_id, NULL);
-
- return TRUE;
+ return success;
}
static gboolean
e_ews_notification_unsubscribe_folder_sync (EEwsNotification *notification,
- const gchar *subscription_id)
+ const gchar *subscription_id,
+ GCancellable *cancellable)
{
EEwsConnection *cnc;
- ESoapRequest *request;
- ESoapResponse *response;
- ESoapParameter *param;
- CamelEwsSettings *settings;
- GError *error = NULL;
- xmlDoc *doc;
+ gboolean success;
g_return_val_if_fail (notification != NULL, FALSE);
g_return_val_if_fail (notification->priv != NULL, FALSE);
@@ -435,76 +290,15 @@ e_ews_notification_unsubscribe_folder_sync (EEwsNotification *notification,
if (!cnc)
return FALSE;
- settings = e_ews_connection_ref_settings (cnc);
+ success = e_ews_connection_unsubscribe_sync (cnc, G_PRIORITY_DEFAULT, subscription_id, cancellable,
NULL);
- msg = e_ews_request_new_with_header (
- settings,
- e_ews_connection_get_uri (cnc),
- e_ews_connection_get_impersonate_user (cnc),
- "Unsubscribe",
- NULL,
- NULL,
- e_ews_connection_get_server_version (cnc),
- E_EWS_EXCHANGE_2010_SP1,
- FALSE,
- FALSE);
-
- g_clear_object (&settings);
-
- if (!msg) {
- g_warning ("%s: Failed to create Soup message for URI '%s'", G_STRFUNC,
e_ews_connection_get_uri (cnc));
- g_object_unref (cnc);
- return FALSE;
- }
-
- e_ews_request_write_string_parameter_with_attribute (
- msg, "SubscriptionId", "messages", subscription_id, NULL, NULL);
-
- e_ews_request_write_footer (msg); /* Complete the footer and print the request */
-
- if (!e_ews_connection_utils_prepare_message (cnc, notification->priv->soup_session, SOUP_MESSAGE
(msg), notification->priv->cancellable)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
- }
-
- g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
-
- soup_session_send_message (notification->priv->soup_session, SOUP_MESSAGE (msg));
- if (!SOUP_STATUS_IS_SUCCESSFUL (SOUP_MESSAGE (msg)->status_code)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
- }
-
- doc = xmlReadMemory (
- SOUP_MESSAGE (msg)->response_body->data,
- SOUP_MESSAGE (msg)->response_body->length,
- "response.xml", NULL, 0);
+ g_signal_emit (notification, signals[SUBSCRIPTION_ID_CHANGED], 0, NULL, NULL);
- response = e_soap_response_new_from_xmldoc (doc);
- g_object_unref (msg);
g_object_unref (cnc);
- param = e_soap_response_get_first_parameter_by_name (response, "ResponseMessages", &error);
-
- /* Sanity check */
- g_warn_if_fail ((param != NULL && error == NULL) || (param == NULL && error != NULL));
-
- g_object_unref (response);
-
- if (error != NULL) {
- g_warning (G_STRLOC ": %s\n", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- g_signal_emit (notification, signals[SUBSCRIPTION_ID_CHANGED], 0, NULL, NULL);
-
- return TRUE;
+ return success;
}
-
static EEwsNotificationEvent *
get_folder_event_info (ESoapParameter *param,
EEwsNotificationEventType event_type)
@@ -652,35 +446,13 @@ ews_notification_fire_events_from_response (EEwsNotification *notification,
return TRUE;
}
-static gboolean
-ews_abort_session_idle_cb (gpointer user_data)
-{
- SoupSession *session = user_data;
-
- g_return_val_if_fail (SOUP_IS_SESSION (session), FALSE);
-
- soup_session_abort (session);
-
- return FALSE;
-}
-
-static void
-ews_notification_schedule_abort (SoupSession *session)
-{
- g_return_if_fail (SOUP_IS_SESSION (session));
-
- g_idle_add_full (G_PRIORITY_HIGH_IDLE, ews_abort_session_idle_cb, g_object_ref (session),
g_object_unref);
-}
-
static void
-ews_notification_soup_got_chunk (SoupMessage *msg,
- SoupBuffer *chunk,
- gpointer user_data)
+ews_notification_process_chunk (EEwsNotification *notification,
+ GByteArray *chunk_data,
+ GCancellable *cancellable)
{
- EEwsNotification *notification = user_data;
const gchar *chunk_str;
gsize chunk_len;
- gboolean keep_parsing = TRUE;
/*
* Here we receive, in chunks, "well-formed" messages that contain:
@@ -691,27 +463,20 @@ ews_notification_soup_got_chunk (SoupMessage *msg,
* division -- one part already read, the other just arriving)
*
* We are parsing those chunks in the following way:
- * 1. Append newly arrived chunk->data to notification->priv->chunk->data
- * 2. Search for </Envelope> in notification->priv->chunk->data
- * 3.1 </Envelope> is not found: Do nothing. Waiting for the next chunk
- * 3.2 </Envelope> is found: Get the pair <Envelope>...</Envelope> and handle it
- * 4. Update the notification->priv->chunk->{data,len}, removing the pair used in 3.2
- * 5. Repeat from 2, until that 3.1 happens
+ * 1. Search for </Envelope> in chunk_data
+ * 2.1 </Envelope> is not found: Do nothing. Waiting for the next chunk
+ * 2.2 </Envelope> is found: Get the pair <Envelope>...</Envelope> and handle it
+ * 3. Update the chunk_data, removing the pair used in 2.2
+ * 4. Repeat from 1, until the 2.1 happens
*/
- if (notification->priv->chunk == NULL)
- notification->priv->chunk = g_byte_array_new ();
-
- notification->priv->chunk =
- g_byte_array_append (notification->priv->chunk, (guint8 *) chunk->data, chunk->length);
- chunk_str = (gchar *) notification->priv->chunk->data;
- chunk_len = notification->priv->chunk->len;
+ chunk_str = (const gchar *) chunk_data->data;
+ chunk_len = chunk_data->len;
do {
ESoapResponse *response;
const gchar *end;
gsize len;
- gboolean cancelled = FALSE;
end = g_strstr_len (chunk_str, chunk_len, "</Envelope>");
@@ -725,72 +490,19 @@ ews_notification_soup_got_chunk (SoupMessage *msg,
break;
if (!ews_notification_fire_events_from_response (notification, response)) {
- ews_notification_schedule_abort (notification->priv->soup_session);
-
g_object_unref (response);
break;
}
g_object_unref (response);
- notification->priv->chunk = g_byte_array_remove_range (notification->priv->chunk, 0, len);
-
- chunk_str = (gchar *) notification->priv->chunk->data;
- chunk_len = notification->priv->chunk->len;
-
- cancelled = g_cancellable_is_cancelled (notification->priv->cancellable);
- if (chunk_len == 0 || cancelled) {
- g_byte_array_free (notification->priv->chunk, TRUE);
- notification->priv->chunk = NULL;
- keep_parsing = FALSE;
-
- if (cancelled) {
- /* Abort any pending operations, but not here, rather in another thread */
- ews_notification_schedule_abort (notification->priv->soup_session);
- }
- }
- } while (keep_parsing);
-}
-
-typedef struct _NotifcationCancelData {
- SoupSession *session;
- SoupMessage *msg;
-} NotifcationCancelData;
-
-static NotifcationCancelData *
-notifcation_cancel_data_new (SoupSession *session,
- SoupMessage *msg)
-{
- NotifcationCancelData *ncd;
-
- ncd = g_slice_new (NotifcationCancelData);
- ncd->session = g_object_ref (session);
- ncd->msg = g_object_ref (msg);
-
- return ncd;
-}
-
-static void
-notifcation_cancel_data_free (gpointer ptr)
-{
- NotifcationCancelData *ncd = ptr;
+ g_byte_array_remove_range (chunk_data, 0, len);
- if (ncd) {
- g_clear_object (&ncd->session);
- g_clear_object (&ncd->msg);
- g_slice_free (NotifcationCancelData, ncd);
- }
+ chunk_str = (gchar *) chunk_data->data;
+ chunk_len = chunk_data->len;
+ } while (chunk_len > 0 && !g_cancellable_is_cancelled (cancellable));
}
-static void
-ews_notification_cancelled_cb (GCancellable *cancellable,
- gpointer user_data)
-{
- NotifcationCancelData *ncd = user_data;
-
- g_return_if_fail (ncd != NULL);
-
- soup_session_cancel_message (ncd->session, ncd->msg, SOUP_STATUS_CANCELLED);
-}
+#define BUFFER_SIZE 16384
static gboolean
e_ews_notification_get_events_sync (EEwsNotification *notification,
@@ -799,11 +511,12 @@ e_ews_notification_get_events_sync (EEwsNotification *notification,
GCancellable *cancellable)
{
EEwsConnection *cnc;
- ESoapRequest *request;
- CamelEwsSettings *settings;
- gboolean ret;
- gulong handler_id, cancel_handler_id;
- guint status_code;
+ GInputStream *input_stream = NULL;
+ GByteArray *chunk_data;
+ gpointer buffer;
+ gssize nread = 0;
+ gboolean success;
+ GError *local_error = NULL;
g_return_val_if_fail (out_fatal_error != NULL, FALSE);
@@ -820,69 +533,36 @@ e_ews_notification_get_events_sync (EEwsNotification *notification,
if (!cnc)
return FALSE;
- settings = e_ews_connection_ref_settings (cnc);
-
- msg = e_ews_request_new_with_header (
- settings,
- e_ews_connection_get_uri (cnc),
- e_ews_connection_get_impersonate_user (cnc),
- "GetStreamingEvents",
- NULL,
- NULL,
- e_ews_connection_get_server_version (cnc),
- E_EWS_EXCHANGE_2010_SP1,
- FALSE,
- FALSE);
-
- g_clear_object (&settings);
-
- if (!msg) {
- g_warning ("%s: Failed to create Soup message for URI '%s'", G_STRFUNC,
e_ews_connection_get_uri (cnc));
- g_object_unref (cnc);
+ if (!e_ews_connection_get_streaming_events_sync (cnc, G_PRIORITY_DEFAULT, subscription_id,
&input_stream, cancellable, &local_error) || !input_stream) {
+ *out_fatal_error = !local_error || local_error->domain == E_SOUP_SESSION_ERROR ||
local_error->domain == G_TLS_ERROR;
+ g_clear_object (&cnc);
+ g_clear_error (&local_error);
return FALSE;
}
- e_soap_request_start_element (msg, "SubscriptionIds", "messages", NULL);
- e_ews_request_write_string_parameter_with_attribute (msg, "SubscriptionId", NULL, subscription_id,
NULL, NULL);
- e_soap_request_end_element (msg); /* SubscriptionIds */
+ /* Unref early, thus it can be freed and will cancel this thread. */
+ g_clear_object (&cnc);
- e_ews_request_write_string_parameter_with_attribute (msg, "ConnectionTimeout", "messages", "10",
NULL, NULL);
+ chunk_data = g_byte_array_new ();
+ buffer = g_malloc (BUFFER_SIZE);
- e_ews_request_write_footer (msg); /* Complete the footer and print the request */
-
- handler_id = g_signal_connect (
- SOUP_MESSAGE (msg), "got-chunk",
- G_CALLBACK (ews_notification_soup_got_chunk), notification);
-
- if (!e_ews_connection_utils_prepare_message (cnc, notification->priv->soup_session, SOUP_MESSAGE
(msg), notification->priv->cancellable)) {
- g_object_unref (msg);
- g_object_unref (cnc);
- return FALSE;
+ while (nread = g_input_stream_read (input_stream, buffer, BUFFER_SIZE, cancellable, &local_error),
+ nread > 0) {
+ g_byte_array_append (chunk_data, buffer, nread);
+ ews_notification_process_chunk (notification, chunk_data, cancellable);
}
- /* Unref it early, thus it doesn't keep the connection alive after all backends are freed */
- g_object_unref (cnc);
-
- cancel_handler_id = g_cancellable_connect (cancellable, G_CALLBACK (ews_notification_cancelled_cb),
- notifcation_cancel_data_new (notification->priv->soup_session, SOUP_MESSAGE (msg)),
notifcation_cancel_data_free);
-
- g_signal_connect (msg, "authenticate", G_CALLBACK (ews_notification_authenticate), notification);
-
- if (g_cancellable_is_cancelled (cancellable))
- status_code = SOUP_STATUS_CANCELLED;
- else
- status_code = soup_session_send_message (notification->priv->soup_session, SOUP_MESSAGE
(msg));
-
- if (cancel_handler_id > 0)
- g_cancellable_disconnect (cancellable, cancel_handler_id);
+ g_free (buffer);
+ g_byte_array_unref (chunk_data);
+ g_clear_object (&input_stream);
- ret = SOUP_STATUS_IS_SUCCESSFUL (status_code);
- *out_fatal_error = SOUP_STATUS_IS_CLIENT_ERROR (status_code) || SOUP_STATUS_IS_SERVER_ERROR
(status_code) || status_code == SOUP_STATUS_CANCELLED;
+ /* It's okay when read failed on EOF */
+ *out_fatal_error = local_error != NULL || g_cancellable_is_cancelled (cancellable);
+ success = !local_error && !*out_fatal_error;
- g_signal_handler_disconnect (msg, handler_id);
- g_object_unref (msg);
+ g_clear_error (&local_error);
- return ret;
+ return success;
}
static gpointer
@@ -914,7 +594,7 @@ e_ews_notification_get_events_thread (gpointer user_data)
}
if (td->notification->priv->last_subscription_id) {
- e_ews_notification_unsubscribe_folder_sync (td->notification,
td->notification->priv->last_subscription_id);
+ e_ews_notification_unsubscribe_folder_sync (td->notification,
td->notification->priv->last_subscription_id, td->cancellable);
g_clear_pointer (&td->notification->priv->last_subscription_id, g_free);
}
@@ -930,7 +610,7 @@ e_ews_notification_get_events_thread (gpointer user_data)
if (!ret && !g_cancellable_is_cancelled (td->cancellable)) {
g_debug ("%s: Failed to get notification events (SubscriptionId: '%s')", G_STRFUNC,
subscription_id);
- e_ews_notification_unsubscribe_folder_sync (td->notification, subscription_id);
+ e_ews_notification_unsubscribe_folder_sync (td->notification, subscription_id,
td->cancellable);
g_free (subscription_id);
subscription_id = NULL;
@@ -947,7 +627,7 @@ e_ews_notification_get_events_thread (gpointer user_data)
exit:
if (subscription_id != NULL) {
- e_ews_notification_unsubscribe_folder_sync (td->notification, subscription_id);
+ e_ews_notification_unsubscribe_folder_sync (td->notification, subscription_id,
td->cancellable);
g_free (subscription_id);
}
diff --git a/src/EWS/common/e-ews-notification.h b/src/EWS/common/e-ews-notification.h
index 4e85e541..2567d48e 100644
--- a/src/EWS/common/e-ews-notification.h
+++ b/src/EWS/common/e-ews-notification.h
@@ -41,6 +41,9 @@ struct _EEwsNotificationClass {
};
GType e_ews_notification_get_type (void);
+const gchar * const *
+ e_ews_notification_get_event_names
+ (void);
EEwsNotification *
e_ews_notification_new (EEwsConnection *connection,
gchar *last_subscription_id); /* assumes ownership of it */
diff --git a/src/EWS/common/e-ews-oof-settings.c b/src/EWS/common/e-ews-oof-settings.c
index be96d441..a08c4f93 100644
--- a/src/EWS/common/e-ews-oof-settings.c
+++ b/src/EWS/common/e-ews-oof-settings.c
@@ -631,7 +631,7 @@ ews_oof_settings_submit_thread (GTask *task,
SubmitData *sd = task_data;
GError *error = NULL;
- if (ews_oof_settings_call_submit_sync (E_EWS_OOF_SETTINGS (source_object), sd, cancellable, error))
+ if (ews_oof_settings_call_submit_sync (E_EWS_OOF_SETTINGS (source_object), sd, cancellable, &error))
g_task_return_boolean (task, TRUE);
else
g_task_return_error (task, error);
diff --git a/src/EWS/common/e-ews-query-to-restriction.c b/src/EWS/common/e-ews-query-to-restriction.c
index 2325b8ca..7f0a93d6 100644
--- a/src/EWS/common/e-ews-query-to-restriction.c
+++ b/src/EWS/common/e-ews-query-to-restriction.c
@@ -1302,7 +1302,7 @@ e_ews_query_check_applicable (const gchar *query,
if (!e_ews_check_is_query (query, type))
return FALSE;
- ctx.msg = NULL;
+ ctx.req = NULL;
ctx.any_applicable = FALSE;
e_ews_convert_sexp_to_restriction (&ctx, query, type);
diff --git a/src/EWS/common/e-ews-request.c b/src/EWS/common/e-ews-request.c
index 26dcfb30..083e5b40 100644
--- a/src/EWS/common/e-ews-request.c
+++ b/src/EWS/common/e-ews-request.c
@@ -9,7 +9,7 @@
#include "evolution-ews-config.h"
#include <string.h>
-#include <libsoup/soup-uri.h>
+#include <libsoup/soup.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
@@ -49,21 +49,21 @@ convert_server_version_to_string (EEwsServerVersion version)
}
ESoapRequest *
-e_ews_request_new_with_header (CamelEwsSettings *settings,
- const gchar *uri,
+e_ews_request_new_with_header (const gchar *uri,
const gchar *impersonate_user,
const gchar *method_name,
const gchar *attribute_name,
const gchar *attribute_value,
EEwsServerVersion server_version,
EEwsServerVersion minimum_version,
- gboolean force_minimum_version)
+ gboolean force_minimum_version,
+ GError **error)
{
ESoapRequest *req;
const gchar *server_ver;
EEwsServerVersion version;
- req = e_soap_request_new (SOUP_METHOD_POST, uri, FALSE, NULL, NULL, NULL);
+ req = e_soap_request_new (SOUP_METHOD_POST, uri, FALSE, NULL, NULL, NULL, error);
if (req == NULL) {
g_warning ("%s: Could not build SOAP message for uri '%s'", G_STRFUNC, uri);
return NULL;
@@ -197,8 +197,6 @@ e_ews_request_write_footer (ESoapRequest *req)
e_soap_request_end_element (req);
e_soap_request_end_body (req);
e_soap_request_end_envelope (req);
-
- e_soap_request_persist (req);
}
void
diff --git a/src/EWS/common/e-ews-request.h b/src/EWS/common/e-ews-request.h
index 13361161..3a7e9973 100644
--- a/src/EWS/common/e-ews-request.h
+++ b/src/EWS/common/e-ews-request.h
@@ -31,7 +31,8 @@ ESoapRequest * e_ews_request_new_with_header (const gchar *uri,
const gchar *attribute_value,
EEwsServerVersion server_version,
EEwsServerVersion minimum_version,
- gboolean force_minimum_version);
+ gboolean force_minimum_version,
+ GError **error);
void e_ews_request_write_string_parameter
(ESoapRequest *req,
const gchar *name,
diff --git a/src/EWS/common/e-soap-request.c b/src/EWS/common/e-soap-request.c
index 9acda9dd..b4b744da 100644
--- a/src/EWS/common/e-soap-request.c
+++ b/src/EWS/common/e-soap-request.c
@@ -12,13 +12,12 @@
#include <stdio.h>
#include <errno.h>
#include <libsoup/soup.h>
-#ifdef G_OS_WIN32
-#include <io.h>
-#endif
-#include "e-soap-request.h"
+#include "e-ews-connection-utils.h"
#include "e-ews-debug.h"
+#include "e-soap-request.h"
+
struct _ESoapRequestPrivate {
gchar *method;
GUri *uri;
@@ -35,11 +34,13 @@ struct _ESoapRequestPrivate {
gchar *etag;
+ gchar *store_node_data_nodename;
+ gchar *store_node_data_directory;
+ gboolean store_node_data_base64;
+
gchar *certificate_pem;
GTlsCertificateFlags certificate_errors;
- /* Serialization fields */
- xmlParserCtxtPtr ctxt;
xmlDocPtr doc;
xmlNodePtr last_node;
xmlNsPtr soap_ns;
@@ -63,6 +64,8 @@ soap_request_finalize (GObject *object)
g_clear_pointer (&req->priv->custom_body_data, g_free);
g_clear_pointer (&req->priv->etag, g_free);
g_clear_pointer (&req->priv->certificate_pem, g_free);
+ g_clear_pointer (&req->priv->store_node_data_nodename, g_free);
+ g_clear_pointer (&req->priv->store_node_data_directory, g_free);
g_clear_pointer (&req->priv->doc, xmlFreeDoc);
g_clear_pointer (&req->priv->action, g_free);
@@ -127,6 +130,7 @@ fetch_ns (ESoapRequest *req,
* @xml_encoding: ??? FIXME
* @env_prefix: ??? FIXME
* @env_uri: ??? FIXME
+ * @error: a #GError, or %NULL
*
* Creates a new empty #ESoapRequest, which will connect to @uri_string.
*
@@ -139,12 +143,13 @@ e_soap_request_new (const gchar *method,
gboolean standalone,
const gchar *xml_encoding,
const gchar *env_prefix,
- const gchar *env_uri)
+ const gchar *env_uri,
+ GError **error)
{
ESoapRequest *req;
GUri *uri;
- uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, NULL);
+ uri = g_uri_parse (uri_string, SOUP_HTTP_URI_FLAGS | G_URI_FLAGS_PARSE_RELAXED, error);
if (!uri)
return NULL;
@@ -893,64 +898,6 @@ e_soap_request_get_progress_fn (ESoapRequest *req,
*out_user_data = req->priv->progress_data;
}
-/**
- * e_soap_request_persist:
- * @req: the #ESoapRequest.
- * @soup_session: an #ESoupSession to create the #SoupMessage for
- * @settings: a #CamelEwsSettings object, to read User-Agent header information from
- * @error: (optional) (out): return location for a #GError, or %NULL
- *
- * Writes the serialized XML tree to the #SoupMessage's buffer.
- *
- * When a custom body was set with e_soap_request_set_custom_body(), then that body
- * is used instead.
- *
- * Returns: (nullable) (transfer full): a #SoupMessage containing the SOAP request
- * as its request body, or %NULL on error.
- */
-SoupMessage *
-e_soap_request_persist (ESoapRequest *req,
- ESoupSession *soup_session,
- CamelEwsSettings *settings,
- GError **error)
-{
- SoupMessage *message;
-
- g_return_val_if_fail (E_IS_SOAP_REQUEST (req), NULL);
-
- message = e_soup_session_new_message_from_uri (soup_session, req->priv->method, req->priv->uri,
error);
-
- if (!message)
- return NULL;
-
- if (req->priv->custom_body_content_type) {
- /* Can use empty string as content_type to indicate no body to be set */
- if (*req->priv->custom_body_content_type && req->priv->custom_body_data) {
- e_soup_session_util_set_message_request_body_from_data (message, TRUE,
- req->priv->custom_body_content_type,
- req->priv->custom_body_data,
- req->priv->custom_body_data_len, NULL);
- }
- } else {
- xmlChar *body;
- gint len;
-
- xmlDocDumpMemory (req->priv->doc, &body, &len);
-
- e_soup_session_util_set_message_request_body_from_data (message, FALSE,
- "text/xml; charset=utf-8", body, len, (GDestroyNotify) xmlFree);
- }
-
- e_ews_connection_utils_set_user_agent_header (message, settings);
-
- soup_message_headers_replace (soup_message_get_request_headers (message), "Connection", "Keep-Alive");
-
- if (req->priv->etag && *req->priv->etag)
- soup_message_headers_replace (soup_message_get_request_headers (soup_message),
"If-None-Match", req->priv->etag);
-
- return message;
-}
-
/**
* e_soap_request_set_custom_body:
* @req: the #ESoapRequest.
@@ -969,12 +916,12 @@ void
e_soap_request_set_custom_body (ESoapRequest *req,
const gchar *content_type,
gconstpointer body,
- gsize body_len)
+ gssize body_len)
{
- g_return_val_if_fail (E_IS_SOAP_REQUEST (req), NULL);
+ g_return_if_fail (E_IS_SOAP_REQUEST (req));
if (content_type && *content_type)
- g_return_val_if_fail (body != NULL, NULL);
+ g_return_if_fail (body != NULL);
g_clear_pointer (&req->priv->custom_body_content_type, g_free);
g_clear_pointer (&req->priv->custom_body_data, g_free);
@@ -1089,3 +1036,110 @@ e_soap_request_get_etag (ESoapRequest *req)
return req->priv->etag;
}
+
+void
+e_soap_request_set_store_node_data (ESoapRequest *req,
+ const gchar *nodename,
+ const gchar *directory,
+ gboolean base64)
+{
+ g_return_if_fail (E_IS_SOAP_REQUEST (req));
+
+ if (g_strcmp0 (req->priv->store_node_data_nodename, nodename) != 0) {
+ g_free (req->priv->store_node_data_nodename);
+ req->priv->store_node_data_nodename = g_strdup (nodename);
+ }
+
+ if (g_strcmp0 (req->priv->store_node_data_directory, directory) != 0) {
+ g_free (req->priv->store_node_data_directory);
+ req->priv->store_node_data_directory = g_strdup (directory);
+ }
+
+ req->priv->store_node_data_base64 = base64;
+}
+
+void
+e_soap_request_get_store_node_data (ESoapRequest *req,
+ const gchar **out_nodename,
+ const gchar **out_directory,
+ gboolean *out_base64)
+{
+ g_return_if_fail (E_IS_SOAP_REQUEST (req));
+ g_return_if_fail (out_nodename != NULL);
+ g_return_if_fail (out_directory != NULL);
+ g_return_if_fail (out_base64 != NULL);
+
+ *out_nodename = req->priv->store_node_data_nodename;
+ *out_directory = req->priv->store_node_data_directory;
+ *out_base64 = req->priv->store_node_data_base64;
+}
+
+/**
+ * e_soap_request_persist:
+ * @req: the #ESoapRequest.
+ * @soup_session: an #ESoupSession to create the #SoupMessage for
+ * @settings: a #CamelEwsSettings object, to read User-Agent header information from
+ * @error: (optional) (out): return location for a #GError, or %NULL
+ *
+ * Writes the serialized XML tree to the #SoupMessage's buffer.
+ *
+ * When a custom body was set with e_soap_request_set_custom_body(), then that body
+ * is used instead.
+ *
+ * Returns: (nullable) (transfer full): a #SoupMessage containing the SOAP request
+ * as its request body, or %NULL on error.
+ */
+SoupMessage *
+e_soap_request_persist (ESoapRequest *req,
+ ESoupSession *soup_session,
+ CamelEwsSettings *settings,
+ GError **error)
+{
+ SoupMessage *message;
+
+ g_return_val_if_fail (E_IS_SOAP_REQUEST (req), NULL);
+
+ message = e_soup_session_new_message_from_uri (soup_session, req->priv->method, req->priv->uri,
error);
+
+ if (!message)
+ return NULL;
+
+ if (req->priv->custom_body_content_type) {
+ /* Can use empty string as content_type to indicate no body to be set */
+ if (*req->priv->custom_body_content_type && req->priv->custom_body_data) {
+ e_soup_session_util_set_message_request_body_from_data (message, TRUE,
+ req->priv->custom_body_content_type,
+ req->priv->custom_body_data,
+ req->priv->custom_body_data_len, NULL);
+ }
+ } else {
+ xmlChar *body;
+ gint len;
+
+ xmlDocDumpMemory (req->priv->doc, &body, &len);
+
+ e_soup_session_util_set_message_request_body_from_data (message, FALSE,
+ "text/xml; charset=utf-8", body, len, (GDestroyNotify) xmlFree);
+ }
+
+ e_ews_connection_utils_set_user_agent_header (message, settings);
+
+ soup_message_headers_replace (soup_message_get_request_headers (message), "Connection", "Keep-Alive");
+
+ if (req->priv->etag && *req->priv->etag)
+ soup_message_headers_replace (soup_message_get_request_headers (message), "If-None-Match",
req->priv->etag);
+
+ return message;
+}
+
+void
+e_soap_request_setup_response (ESoapRequest *req,
+ ESoapResponse *response)
+{
+ g_return_if_fail (E_IS_SOAP_REQUEST (req));
+ g_return_if_fail (E_IS_SOAP_RESPONSE (response));
+
+ e_soap_response_set_progress_fn (response, req->priv->progress_fn, req->priv->progress_data);
+ e_soap_response_set_store_node_data (response, req->priv->store_node_data_nodename,
+ req->priv->store_node_data_directory, req->priv->store_node_data_base64);
+}
diff --git a/src/EWS/common/e-soap-request.h b/src/EWS/common/e-soap-request.h
index e3ac9894..fddff613 100644
--- a/src/EWS/common/e-soap-request.h
+++ b/src/EWS/common/e-soap-request.h
@@ -35,18 +35,18 @@
G_BEGIN_DECLS
-typedef gboolean (* ESoapRequestCustomProcessFn) (ESoupaRequest *request,
- SoupMessage *message,
- GInputStream *input_stream,
- gpointer user_data,
- gboolean *out_repeat,
- GCancellable *cancellable,
- GError **error);
-
typedef struct _ESoapRequest ESoapRequest;
typedef struct _ESoapRequestClass ESoapRequestClass;
typedef struct _ESoapRequestPrivate ESoapRequestPrivate;
+typedef void (* ESoapRequestCustomProcessFn) (ESoapRequest *request,
+ SoupMessage *message,
+ GInputStream *input_stream,
+ gpointer user_data,
+ gboolean *out_repeat,
+ GCancellable *cancellable,
+ GError **error);
+
struct _ESoapRequest {
GObject parent;
ESoapRequestPrivate *priv;
@@ -62,7 +62,8 @@ ESoapRequest * e_soap_request_new (const gchar *method,
gboolean standalone,
const gchar *xml_encoding,
const gchar *env_prefix,
- const gchar *env_uri);
+ const gchar *env_uri,
+ GError **error);
ESoapRequest * e_soap_request_new_from_uri (const gchar *method,
GUri *uri,
gboolean standalone,
@@ -142,10 +143,16 @@ void e_soap_request_set_progress_fn (ESoapRequest *req,
void e_soap_request_get_progress_fn (ESoapRequest *req,
ESoapResponseProgressFn *out_fn,
gpointer *out_user_data);
-SoupMessage * e_soap_request_persist (ESoapRequest *req,
- ESoupSession *soup_session,
- CamelEwsSettings *settings,
- GError **error);
+void e_soap_request_set_store_node_data
+ (ESoapRequest *req,
+ const gchar *nodename,
+ const gchar *directory,
+ gboolean base64);
+void e_soap_request_get_store_node_data
+ (ESoapRequest *req,
+ const gchar **out_nodename,
+ const gchar **out_directory,
+ gboolean *out_base64);
void e_soap_request_set_custom_body (ESoapRequest *req,
const gchar *content_type,
gconstpointer body,
@@ -169,7 +176,12 @@ gboolean e_soap_request_get_tls_error_details
void e_soap_request_set_etag (ESoapRequest *req,
const gchar *etag);
const gchar * e_soap_request_get_etag (ESoapRequest *req);
-
+SoupMessage * e_soap_request_persist (ESoapRequest *req,
+ ESoupSession *soup_session,
+ CamelEwsSettings *settings,
+ GError **error);
+void e_soap_request_setup_response (ESoapRequest *req,
+ ESoapResponse *response);
G_END_DECLS
#endif /* E_SOAP_REQUEST_H */
diff --git a/src/EWS/common/e-soap-response.c b/src/EWS/common/e-soap-response.c
index 609d36bb..74cf49d8 100644
--- a/src/EWS/common/e-soap-response.c
+++ b/src/EWS/common/e-soap-response.c
@@ -23,6 +23,9 @@ struct _ESoapResponsePrivate {
xmlNodePtr soap_fault;
GList *parameters;
+ /* Serialization fields */
+ xmlParserCtxtPtr ctxt;
+
/* Content stealing */
gchar *steal_node;
gchar *steal_dir;
@@ -33,7 +36,7 @@ struct _ESoapResponsePrivate {
gint steal_fd;
/* Progress callbacks */
- ESoapProgressFn progress_fn;
+ ESoapResponseProgressFn progress_fn;
gpointer progress_data;
};
@@ -281,7 +284,7 @@ soap_sax_startElementNs (gpointer _ctxt,
const xmlChar **attributes)
{
xmlParserCtxt *ctxt = _ctxt;
- ESoapRequest *ews_msg = ctxt->_private;
+ ESoapResponse *response = ctxt->_private;
gchar *fname;
xmlSAX2StartElementNs (
@@ -290,8 +293,8 @@ soap_sax_startElementNs (gpointer _ctxt,
attributes);
/* steal_node can contain multiple node name separated by " " */
- if (ews_msg->priv->steal_node && *ews_msg->priv->steal_node) {
- gchar **prop = g_strsplit (ews_msg->priv->steal_node, " ", 0);
+ if (response->priv->steal_node && *response->priv->steal_node) {
+ gchar **prop = g_strsplit (response->priv->steal_node, " ", 0);
gint i = 0;
gboolean isnode = FALSE;
@@ -308,10 +311,10 @@ soap_sax_startElementNs (gpointer _ctxt,
} else
return;
- fname = g_build_filename (ews_msg->priv->steal_dir, "XXXXXX", NULL);
- ews_msg->priv->steal_fd = g_mkstemp (fname);
- if (ews_msg->priv->steal_fd != -1) {
- if (ews_msg->priv->steal_base64) {
+ fname = g_build_filename (response->priv->steal_dir, "XXXXXX", NULL);
+ response->priv->steal_fd = g_mkstemp (fname);
+ if (response->priv->steal_fd != -1) {
+ if (response->priv->steal_base64) {
gchar *enc = g_base64_encode ((guchar *) fname, strlen (fname));
xmlSAX2Characters (ctxt, (xmlChar *) enc, strlen (enc));
g_free (enc);
@@ -332,11 +335,11 @@ soap_sax_endElementNs (gpointer _ctxt,
const xmlChar *uri)
{
xmlParserCtxt *ctxt = _ctxt;
- ESoapRequest *ews_msg = ctxt->_private;
+ ESoapResponse *response = ctxt->_private;
- if (ews_msg->priv->steal_fd != -1) {
- close (ews_msg->priv->steal_fd);
- ews_msg->priv->steal_fd = -1;
+ if (response->priv->steal_fd != -1) {
+ close (response->priv->steal_fd);
+ response->priv->steal_fd = -1;
}
xmlSAX2EndElementNs (ctxt, localname, prefix, uri);
}
@@ -347,12 +350,12 @@ soap_sax_characters (gpointer _ctxt,
gint len)
{
xmlParserCtxt *ctxt = _ctxt;
- ESoapRequest *ews_msg = ctxt->_private;
+ ESoapResponse *response = ctxt->_private;
- if (ews_msg->priv->steal_fd == -1)
+ if (response->priv->steal_fd == -1)
xmlSAX2Characters (ctxt, ch, len);
- else if (!ews_msg->priv->steal_base64) {
- if (write (ews_msg->priv->steal_fd, (const gchar *) ch, len) != len) {
+ else if (!response->priv->steal_base64) {
+ if (write (response->priv->steal_fd, (const gchar *) ch, len) != len) {
write_err:
/* Handle error better */
g_warning ("Failed to write streaming data to file");
@@ -363,9 +366,9 @@ soap_sax_characters (gpointer _ctxt,
blen = g_base64_decode_step (
(const gchar *) ch, len,
- bdata, &ews_msg->priv->steal_b64_state,
- &ews_msg->priv->steal_b64_save);
- if (write (ews_msg->priv->steal_fd, (const gchar *) bdata, blen) != blen) {
+ bdata, &response->priv->steal_b64_state,
+ &response->priv->steal_b64_save);
+ if (write (response->priv->steal_fd, (const gchar *) bdata, blen) != blen) {
g_free (bdata);
goto write_err;
}
@@ -383,7 +386,7 @@ e_soap_response_xmldoc_from_message_sync (ESoapResponse *response,
GError **error)
{
const gchar *size;
- xmlDoc xmldoc = NULL;
+ xmlDoc *xmldoc = NULL;
gboolean success;
gpointer buffer;
gsize response_size = 0;
@@ -392,7 +395,7 @@ e_soap_response_xmldoc_from_message_sync (ESoapResponse *response,
gsize nread = 0;
g_return_val_if_fail (E_IS_SOAP_RESPONSE (response), FALSE);
- g_return_val_if_fail (SOAP_IS_MESSAGE (msg), FALSE);
+ g_return_val_if_fail (SOUP_IS_MESSAGE (msg), FALSE);
g_return_val_if_fail (G_IS_INPUT_STREAM (response_data), FALSE);
/* Discard the existing context, if there is one, and start again */
@@ -408,14 +411,14 @@ e_soap_response_xmldoc_from_message_sync (ESoapResponse *response,
response->priv->steal_fd = -1;
}
- size = soup_message_headers_get_one (soup_message_get_response_headers (soup_msg), "Content-Length");
+ size = soup_message_headers_get_one (soup_message_get_response_headers (msg), "Content-Length");
if (size)
response_size = g_ascii_strtoll (size, NULL, 10);
buffer = g_malloc (BUFFER_SIZE);
- while (success = g_input_stream_read_all (input_stream, buffer, BUFFER_SIZE, &nread, cancellable,
error),
+ while (success = g_input_stream_read_all (response_data, buffer, BUFFER_SIZE, &nread, cancellable,
error),
success && nread > 0) {
response_received += nread;
@@ -428,7 +431,7 @@ e_soap_response_xmldoc_from_message_sync (ESoapResponse *response,
}
if (!response->priv->ctxt) {
- response->priv->ctxt = xmlCreatePushParserCtxt (NULL, req, buffer, nread, NULL);
+ response->priv->ctxt = xmlCreatePushParserCtxt (NULL, response, buffer, nread, NULL);
response->priv->ctxt->_private = response;
response->priv->ctxt->sax->startElementNs = soap_sax_startElementNs;
response->priv->ctxt->sax->endElementNs = soap_sax_endElementNs;
@@ -442,8 +445,6 @@ e_soap_response_xmldoc_from_message_sync (ESoapResponse *response,
if (success) {
if (response->priv->ctxt) {
- xmlDocPtr xmldoc;
-
xmlParseChunk (response->priv->ctxt, 0, 0, 1);
xmldoc = response->priv->ctxt->myDoc;
@@ -479,10 +480,10 @@ e_soap_response_from_message_sync (ESoapResponse *response,
GError **error)
{
xmlDoc *xmldoc;
- gboolean successs = FALSE;
+ gboolean success = FALSE;
g_return_val_if_fail (E_IS_SOAP_RESPONSE (response), FALSE);
- g_return_val_if_fail (SOAP_IS_MESSAGE (msg), FALSE);
+ g_return_val_if_fail (SOUP_IS_MESSAGE (msg), FALSE);
g_return_val_if_fail (G_IS_INPUT_STREAM (response_data), FALSE);
xmldoc = e_soap_response_xmldoc_from_message_sync (response, msg, response_data, cancellable, error);
@@ -497,7 +498,7 @@ e_soap_response_from_message_sync (ESoapResponse *response,
}
/**
- * e_soap_response_store_node_data:
+ * e_soap_response_set_store_node_data:
* @response: the %ESoapResponse
* @nodename: the name of the XML node from which to store data
* @directory: cache directory in which to create data files
@@ -510,10 +511,10 @@ e_soap_response_from_message_sync (ESoapResponse *response,
* It is used only with e_soap_response_from_message_sync().
*/
void
-e_soap_response_store_node_data (ESoapResponse *response,
- const gchar *nodename,
- const gchar *directory,
- gboolean base64)
+e_soap_response_set_store_node_data (ESoapResponse *response,
+ const gchar *nodename,
+ const gchar *directory,
+ gboolean base64)
{
g_return_if_fail (E_IS_SOAP_RESPONSE (response));
g_return_if_fail (response->priv->steal_node == NULL);
@@ -861,11 +862,8 @@ e_soap_response_get_first_parameter_by_name (ESoapResponse *response,
string = e_soap_parameter_get_string_value (param);
- g_set_error (
- error,
- SOUP_HTTP_ERROR, SOUP_STATUS_IO_ERROR,
- "%s", (string != NULL) ? string :
- "<faultstring> in SOAP response");
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ (string != NULL) ? string : "<faultstring> in SOAP response");
g_free (string);
@@ -873,9 +871,7 @@ e_soap_response_get_first_parameter_by_name (ESoapResponse *response,
}
}
- g_set_error (
- error,
- SOUP_HTTP_ERROR, SOUP_STATUS_MALFORMED,
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Missing <%s> in SOAP response", name);
return NULL;
diff --git a/src/EWS/common/e-soap-response.h b/src/EWS/common/e-soap-response.h
index 122067f4..19b50856 100644
--- a/src/EWS/common/e-soap-response.h
+++ b/src/EWS/common/e-soap-response.h
@@ -71,7 +71,8 @@ xmlDoc * e_soap_response_xmldoc_from_message_sync
GCancellable *cancellable,
GError **error);
/* used only with e_soap_response_from_message_sync() */
-void e_soap_response_store_node_data (ESoapResponse *response,
+void e_soap_response_set_store_node_data
+ (ESoapResponse *response,
const gchar *nodename,
const gchar *directory,
gboolean base64);
diff --git a/src/EWS/evolution/e-ews-config-lookup.c b/src/EWS/evolution/e-ews-config-lookup.c
index 29f647ed..7e854af7 100644
--- a/src/EWS/evolution/e-ews-config-lookup.c
+++ b/src/EWS/evolution/e-ews-config-lookup.c
@@ -370,7 +370,7 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address, password,
&certificate_pem, &certificate_errors, cancellable, &local_error)) {
ews_config_lookup_worker_result_from_settings (lookup_worker, config_lookup,
email_address, ews_settings, params);
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED)) {
+ } else if (g_error_matches (local_error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE)) {
const gchar *hosturl;
GUri *uri;
@@ -379,7 +379,7 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
if (uri) {
certificate_host = g_strdup (g_uri_get_host (uri));
- g_uri_unref (suri);
+ g_uri_unref (uri);
}
} else {
g_clear_error (&local_error);
@@ -406,7 +406,7 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
if (e_ews_autodiscover_ws_url_sync (source, ews_settings, email_address,
password, &certificate_pem, &certificate_errors, cancellable, &local_error)) {
ews_config_lookup_worker_result_from_settings (lookup_worker,
config_lookup, email_address, ews_settings, params);
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR,
SOUP_STATUS_SSL_FAILED)) {
+ } else if (g_error_matches (local_error, G_TLS_ERROR,
G_TLS_ERROR_BAD_CERTIFICATE)) {
const gchar *hosturl;
GUri *uri;
@@ -427,7 +427,7 @@ ews_config_lookup_worker_run (EConfigLookupWorker *lookup_worker,
g_strfreev (servers_strv);
}
- if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) &&
+ if (g_error_matches (local_error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE) &&
certificate_pem && *certificate_pem && certificate_errors) {
gchar *description = e_trust_prompt_describe_certificate_errors (certificate_errors);
diff --git a/src/EWS/evolution/e-ews-photo-source.c b/src/EWS/evolution/e-ews-photo-source.c
index 732d6390..b58dc8c1 100644
--- a/src/EWS/evolution/e-ews-photo-source.c
+++ b/src/EWS/evolution/e-ews-photo-source.c
@@ -50,45 +50,39 @@ static void ews_photo_source_iface_init (EPhotoSourceInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (EEwsPhotoSource, e_ews_photo_source, E_TYPE_EXTENSION, 0,
G_IMPLEMENT_INTERFACE_DYNAMIC (E_TYPE_PHOTO_SOURCE, ews_photo_source_iface_init))
-typedef struct _PhotoSourceData {
- GMutex lock;
- guint n_running;
- ESimpleAsyncResult *simple;
- GCancellable *cancellable;
-} PhotoSourceData;
-
static void
-ews_photo_source_dec_running (PhotoSourceData *psd)
+ews_photo_source_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
- if (!g_atomic_int_dec_and_test (&psd->n_running))
- return;
+ const gchar *email_address = task_data;
+ GSList *connections, *link;
+ GHashTable *covered_uris;
+ GError *local_error = NULL;
- if (psd->simple)
- e_simple_async_result_complete_idle (psd->simple);
+ /* Most users connect to a single server anyway, thus no big deal doing
+ this in serial, instead of in parallel. */
+ covered_uris = g_hash_table_new_full (camel_strcase_hash, camel_strcase_equal, g_free, NULL);
+ connections = e_ews_connection_list_existing ();
- g_clear_object (&psd->simple);
- g_clear_object (&psd->cancellable);
- g_mutex_clear (&psd->lock);
- g_free (psd);
-}
+ for (link = connections; link; link = g_slist_next (link)) {
+ EEwsConnection *cnc = link->data;
+ gchar *picture_data = NULL;
+ const gchar *uri;
-static void
-ews_photo_source_get_user_photo_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- PhotoSourceData *psd = user_data;
- GCancellable *cancellable = NULL;
- gchar *picture_data = NULL;
- GError *error = NULL;
+ if (!E_IS_EWS_CONNECTION (cnc) ||
+ !e_ews_connection_satisfies_server_version (cnc, E_EWS_EXCHANGE_2013))
+ continue;
- g_return_if_fail (E_IS_EWS_CONNECTION (source_object));
- g_return_if_fail (psd != NULL);
+ uri = e_ews_connection_get_uri (cnc);
+ if (!uri || !*uri || g_hash_table_contains (covered_uris, uri))
+ continue;
- g_mutex_lock (&psd->lock);
+ g_hash_table_insert (covered_uris, g_strdup (uri), NULL);
- if (e_ews_connection_get_user_photo_finish (E_EWS_CONNECTION (source_object), result, &picture_data,
&error)) {
- if (psd->simple && picture_data && *picture_data) {
+ if (e_ews_connection_get_user_photo_sync (cnc, G_PRIORITY_LOW, email_address,
E_EWS_SIZE_REQUESTED_48X48,
+ &picture_data, cancellable, local_error ? NULL : &local_error) && picture_data) {
gsize len = 0;
guchar *decoded;
@@ -99,32 +93,29 @@ ews_photo_source_get_user_photo_cb (GObject *source_object,
stream = g_memory_input_stream_new_from_data (decoded, len, g_free);
decoded = NULL;
- e_simple_async_result_set_op_pointer (psd->simple, stream, g_object_unref);
- e_simple_async_result_complete_idle (psd->simple);
- g_clear_object (&psd->simple);
-
- cancellable = g_object_ref (psd->cancellable);
+ g_task_return_pointer (task, stream, g_object_unref);
+ task = NULL;
+ g_free (decoded);
+ break;
}
g_free (decoded);
}
- } else {
- if (psd->simple && error) {
- e_simple_async_result_take_error (psd->simple, error);
- error = NULL;
- }
}
- g_mutex_unlock (&psd->lock);
-
- ews_photo_source_dec_running (psd);
+ g_slist_free_full (connections, g_object_unref);
+ g_hash_table_destroy (covered_uris);
- if (cancellable)
- g_cancellable_cancel (cancellable);
+ if (task) {
+ if (!local_error) {
+ /* Do not localize the string, it won't go into the UI/be visible to users */
+ g_set_error_literal (&local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Not Found");
+ }
- g_clear_object (&cancellable);
- g_clear_error (&error);
- g_free (picture_data);
+ g_task_return_error (task, local_error);
+ } else {
+ g_clear_error (&local_error);
+ }
}
static void
@@ -134,46 +125,16 @@ ews_photo_source_get_photo (EPhotoSource *photo_source,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GSList *connections, *link;
- GHashTable *covered_uris;
- PhotoSourceData *psd;
+ GTask *task;
g_return_if_fail (E_IS_EWS_PHOTO_SOURCE (photo_source));
g_return_if_fail (email_address != NULL);
- psd = g_new0 (PhotoSourceData, 1);
- psd->n_running = 1;
- psd->simple = e_simple_async_result_new (G_OBJECT (photo_source), callback, user_data,
ews_photo_source_get_photo);
- psd->cancellable = camel_operation_new_proxy (cancellable);
- g_mutex_init (&psd->lock);
-
- covered_uris = g_hash_table_new_full (camel_strcase_hash, camel_strcase_equal, g_free, NULL);
- connections = e_ews_connection_list_existing ();
-
- for (link = connections; link; link = g_slist_next (link)) {
- EEwsConnection *cnc = link->data;
- const gchar *uri;
-
- if (!E_IS_EWS_CONNECTION (cnc) ||
- !e_ews_connection_satisfies_server_version (cnc, E_EWS_EXCHANGE_2013))
- continue;
-
- uri = e_ews_connection_get_uri (cnc);
- if (!uri || !*uri || g_hash_table_contains (covered_uris, uri))
- continue;
-
- g_hash_table_insert (covered_uris, g_strdup (uri), NULL);
-
- g_atomic_int_inc (&psd->n_running);
-
- e_ews_connection_get_user_photo (cnc, G_PRIORITY_LOW, email_address,
E_EWS_SIZE_REQUESTED_48X48,
- psd->cancellable, ews_photo_source_get_user_photo_cb, psd);
- }
-
- g_slist_free_full (connections, g_object_unref);
- g_hash_table_destroy (covered_uris);
-
- ews_photo_source_dec_running (psd);
+ task = g_task_new (photo_source, cancellable, callback, user_data);
+ g_task_set_source_tag (task, ews_photo_source_get_photo);
+ g_task_set_task_data (task, g_strdup (email_address), g_free);
+ g_task_run_in_thread (task, ews_photo_source_thread);
+ g_object_unref (task);
}
static gboolean
@@ -183,31 +144,25 @@ ews_photo_source_get_photo_finish (EPhotoSource *photo_source,
gint *out_priority,
GError **error)
{
- ESimpleAsyncResult *simple;
+ GInputStream *input_stream;
+ gboolean success;
g_return_val_if_fail (E_IS_EWS_PHOTO_SOURCE (photo_source), FALSE);
- g_return_val_if_fail (E_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
-
- g_return_val_if_fail (e_simple_async_result_is_valid (result, G_OBJECT (photo_source),
ews_photo_source_get_photo), FALSE);
+ g_return_val_if_fail (g_task_is_valid (result, photo_source), FALSE);
if (out_priority)
*out_priority = G_PRIORITY_DEFAULT;
- simple = E_SIMPLE_ASYNC_RESULT (result);
-
- if (e_simple_async_result_propagate_error (simple, error))
- return FALSE;
+ input_stream = g_task_propagate_pointer (G_TASK (result), error);
- *out_stream = e_simple_async_result_get_op_pointer (simple);
- if (*out_stream) {
- g_object_ref (*out_stream);
- return TRUE;
- }
+ success = input_stream != NULL;
- /* Do not localize the string, it won't go into the UI/be visible to users */
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Not Found");
+ if (out_stream)
+ *out_stream = input_stream;
+ else
+ g_clear_object (&input_stream);
- return FALSE;
+ return success;
}
static void
diff --git a/src/EWS/evolution/e-mail-config-ews-autodiscover.c
b/src/EWS/evolution/e-mail-config-ews-autodiscover.c
index 08ee9292..78c38843 100644
--- a/src/EWS/evolution/e-mail-config-ews-autodiscover.c
+++ b/src/EWS/evolution/e-mail-config-ews-autodiscover.c
@@ -103,7 +103,7 @@ mail_config_ews_autodiscover_run_cb (GObject *source_object,
if (e_activity_handle_cancellation (async_context->activity, error)) {
/* Do nothing, just free the error below */
- } else if (g_error_matches (error, SOUP_HTTP_ERROR, SOUP_STATUS_SSL_FAILED) &&
+ } else if (g_error_matches (error, G_TLS_ERROR, G_TLS_ERROR_BAD_CERTIFICATE) &&
async_context->certificate_pem && *async_context->certificate_pem &&
async_context->certificate_errors) {
ETrustPromptResponse response;
GtkWidget *parent;
@@ -182,7 +182,7 @@ mail_config_ews_autodiscover_sync (ECredentialsPrompter *prompter,
if (local_error == NULL) {
*out_authenticated = TRUE;
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
+ } else if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
*out_authenticated = FALSE;
g_error_free (local_error);
} else {
@@ -214,7 +214,7 @@ mail_config_ews_autodiscover_run_thread (GTask *task,
cancellable, &local_error);
}
- if (!without_password || g_error_matches (local_error, SOUP_HTTP_ERROR,
SOUP_STATUS_UNAUTHORIZED)) {
+ if (!without_password || g_error_matches (local_error, E_SOUP_SESSION_ERROR,
SOUP_STATUS_UNAUTHORIZED)) {
EShell *shell;
e_ews_connection_utils_force_off_ntlm_auth_check ();
diff --git a/src/EWS/evolution/e-mail-config-ews-delegates-page.c
b/src/EWS/evolution/e-mail-config-ews-delegates-page.c
index 8352624c..ceff8493 100644
--- a/src/EWS/evolution/e-mail-config-ews-delegates-page.c
+++ b/src/EWS/evolution/e-mail-config-ews-delegates-page.c
@@ -1121,104 +1121,58 @@ mail_config_ews_delegates_page_constructed (GObject *object)
e_mail_config_ews_delegates_page_refresh (page);
}
-#define REMOVED_SLIST_KEY "ews-delegate-removed-slist"
-#define ADDED_SLIST_KEY "ews-delegate-added-slist"
-#define CANCELLABLE_KEY "ews-delegate-cancellable"
-
-static void
-mail_config_ews_delegates_page_add_delegate_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
-
- e_ews_connection_add_delegate_finish (
- E_EWS_CONNECTION (source_object), result, &error);
-
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
-
- g_simple_async_result_complete (simple);
-
- g_object_unref (simple);
-}
+typedef struct _SubmitData {
+ EEwsConnection *cnc;
+ gboolean deliver_to_changed;
+ EwsDelegateDeliver deliver_to;
+ GSList *added; /* const EwsDelegateInfo * */
+ GSList *updated; /* const EwsDelegateInfo * */
+ GSList *removed; /* const gchar * */
+} SubmitData;
static void
-mail_config_ews_delegates_page_remove_delegate_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+submit_data_free (gpointer ptr)
{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
-
- e_ews_connection_remove_delegate_finish (
- E_EWS_CONNECTION (source_object), result, &error);
-
- if (error != NULL) {
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
- } else {
- GCancellable *cancellable;
- GSList *list;
-
- cancellable = g_object_get_data (G_OBJECT (simple), CANCELLABLE_KEY);
- list = g_object_get_data (G_OBJECT (simple), ADDED_SLIST_KEY);
- if (list) {
- e_ews_connection_add_delegate (
- E_EWS_CONNECTION (source_object), G_PRIORITY_DEFAULT, NULL, list,
- cancellable, mail_config_ews_delegates_page_add_delegate_cb, g_object_ref
(simple));
- } else {
- g_simple_async_result_complete (simple);
- }
+ SubmitData *sd = ptr;
+
+ if (sd) {
+ g_clear_object (&sd->cnc);
+ g_slist_free (sd->added);
+ g_slist_free (sd->updated);
+ g_slist_free (sd->removed);
+ g_slice_free (SubmitData, sd);
}
-
- g_object_unref (simple);
}
static void
-mail_config_ews_delegates_page_update_delegate_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+mail_config_ews_delegates_page_submit_thread (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
-
- simple = G_SIMPLE_ASYNC_RESULT (user_data);
+ SubmitData *sd = task_data;
+ gboolean success = TRUE;
+ GError *local_error = NULL;
+
+ if (sd->deliver_to_changed || sd->updated) {
+ success = e_ews_connection_update_delegate_sync (sd->cnc, G_PRIORITY_DEFAULT, NULL,
sd->deliver_to, sd->updated,
+ cancellable, &local_error);
+ }
- e_ews_connection_update_delegate_finish (
- E_EWS_CONNECTION (source_object), result, &error);
+ if (success && sd->removed) {
+ success = e_ews_connection_remove_delegate_sync (sd->cnc, G_PRIORITY_DEFAULT, NULL,
sd->removed,
+ cancellable, &local_error);
+ }
- if (error != NULL) {
- g_simple_async_result_take_error (simple, error);
- g_simple_async_result_complete (simple);
- } else {
- GCancellable *cancellable;
- GSList *list;
-
- cancellable = g_object_get_data (G_OBJECT (simple), CANCELLABLE_KEY);
- list = g_object_get_data (G_OBJECT (simple), REMOVED_SLIST_KEY);
- if (list) {
- e_ews_connection_remove_delegate (
- E_EWS_CONNECTION (source_object), G_PRIORITY_DEFAULT, NULL, list,
- cancellable, mail_config_ews_delegates_page_remove_delegate_cb, g_object_ref
(simple));
- } else {
- list = g_object_get_data (G_OBJECT (simple), ADDED_SLIST_KEY);
- if (list) {
- e_ews_connection_add_delegate (
- E_EWS_CONNECTION (source_object), G_PRIORITY_DEFAULT, NULL, list,
- cancellable, mail_config_ews_delegates_page_add_delegate_cb,
g_object_ref (simple));
- } else {
- g_simple_async_result_complete (simple);
- }
- }
+ if (success && sd->added) {
+ success = e_ews_connection_add_delegate_sync (sd->cnc, G_PRIORITY_DEFAULT, NULL, sd->added,
+ cancellable, &local_error);
}
- g_object_unref (simple);
+ if (local_error)
+ g_task_return_error (task, local_error);
+ else
+ g_task_return_boolean (task, success);
}
static gboolean
@@ -1246,25 +1200,29 @@ mail_config_ews_delegates_page_submit (EMailConfigPage *page,
gpointer user_data)
{
EMailConfigEwsDelegatesPage *ews_page;
- GSimpleAsyncResult *simple;
- EwsDelegateDeliver deliver_to;
- GSList *added = NULL, *updated = NULL, *removed = NULL, *iter;
+ GTask *task;
+ SubmitData *sd;
+ GSList *iter;
GHashTable *oldies;
GHashTableIter titer;
gpointer key, value;
ews_page = E_MAIL_CONFIG_EWS_DELEGATES_PAGE (page);
+ sd = g_slice_new0 (SubmitData);
+
+ task = g_task_new (ews_page, cancellable, callback, user_data);
+ g_task_set_source_tag (task, mail_config_ews_delegates_page_submit);
+ g_task_set_task_data (task, sd, submit_data_free);
+ g_task_set_check_cancellable (task, TRUE);
+
g_mutex_lock (&ews_page->priv->delegates_lock);
if (!ews_page->priv->connection) {
g_mutex_unlock (&ews_page->priv->delegates_lock);
- simple = g_simple_async_result_new (
- G_OBJECT (page), callback, user_data,
- mail_config_ews_delegates_page_submit);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
return;
}
@@ -1292,10 +1250,10 @@ mail_config_ews_delegates_page_submit (EMailConfigPage *page,
orig_di = g_hash_table_lookup (oldies, di->user_id->primary_smtp);
if (!orig_di) {
- added = g_slist_prepend (added, di);
+ sd->added = g_slist_prepend (sd->added, di);
} else {
if (!delegate_infos_equal (orig_di, di))
- updated = g_slist_prepend (updated, di);
+ sd->updated = g_slist_prepend (sd->updated, di);
g_hash_table_remove (oldies, di->user_id->primary_smtp);
}
}
@@ -1304,61 +1262,36 @@ mail_config_ews_delegates_page_submit (EMailConfigPage *page,
while (g_hash_table_iter_next (&titer, &key, &value)) {
EwsDelegateInfo *di = value;
- removed = g_slist_prepend (removed, di->user_id);
+ sd->removed = g_slist_prepend (sd->removed, di->user_id);
}
g_hash_table_destroy (oldies);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ews_page->priv->deliver_copy_me_radio)))
- deliver_to = EwsDelegateDeliver_DelegatesAndSendInformationToMe;
+ sd->deliver_to = EwsDelegateDeliver_DelegatesAndSendInformationToMe;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(ews_page->priv->deliver_delegates_only_radio)))
- deliver_to = EwsDelegateDeliver_DelegatesOnly;
+ sd->deliver_to = EwsDelegateDeliver_DelegatesOnly;
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(ews_page->priv->deliver_delegates_and_me_radio)))
- deliver_to = EwsDelegateDeliver_DelegatesAndMe;
+ sd->deliver_to = EwsDelegateDeliver_DelegatesAndMe;
else
- deliver_to = EwsDelegateDeliver_DelegatesAndSendInformationToMe;
+ sd->deliver_to = EwsDelegateDeliver_DelegatesAndSendInformationToMe;
- if (deliver_to == ews_page->priv->deliver_to && !added && !updated && !removed) {
+ if (sd->deliver_to == ews_page->priv->deliver_to && !sd->added && !sd->updated && !sd->removed) {
/* nothing changed, bye bye */
g_mutex_unlock (&ews_page->priv->delegates_lock);
- simple = g_simple_async_result_new (
- G_OBJECT (page), callback, user_data,
- mail_config_ews_delegates_page_submit);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
+ g_task_return_boolean (task, TRUE);
+ g_object_unref (task);
return;
}
- simple = g_simple_async_result_new (
- G_OBJECT (page), callback, user_data,
- mail_config_ews_delegates_page_submit);
-
- g_simple_async_result_set_check_cancellable (simple, cancellable);
-
- g_object_set_data_full (G_OBJECT (simple), REMOVED_SLIST_KEY, removed, (GDestroyNotify) g_slist_free);
- g_object_set_data_full (G_OBJECT (simple), ADDED_SLIST_KEY, added, (GDestroyNotify) g_slist_free);
- if (cancellable)
- g_object_set_data_full (G_OBJECT (simple), CANCELLABLE_KEY, g_object_ref (cancellable),
g_object_unref);
-
- if (deliver_to != ews_page->priv->deliver_to || updated) {
- e_ews_connection_update_delegate (
- ews_page->priv->connection, G_PRIORITY_DEFAULT, NULL, deliver_to, updated,
- cancellable, mail_config_ews_delegates_page_update_delegate_cb, g_object_ref
(simple));
- } else if (removed) {
- e_ews_connection_remove_delegate (
- ews_page->priv->connection, G_PRIORITY_DEFAULT, NULL, removed,
- cancellable, mail_config_ews_delegates_page_remove_delegate_cb, g_object_ref
(simple));
- } else {
- g_warn_if_fail (added != NULL);
+ sd->cnc = g_object_ref (ews_page->priv->connection);
+ sd->deliver_to_changed = sd->deliver_to != ews_page->priv->deliver_to;
- e_ews_connection_add_delegate (
- ews_page->priv->connection, G_PRIORITY_DEFAULT, NULL, added,
- cancellable, mail_config_ews_delegates_page_add_delegate_cb, g_object_ref (simple));
- }
+ g_task_run_in_thread (task, mail_config_ews_delegates_page_submit_thread);
- g_object_unref (simple);
+ g_object_unref (task);
g_mutex_unlock (&ews_page->priv->delegates_lock);
}
@@ -1368,17 +1301,9 @@ mail_config_ews_delegates_page_submit_finish (EMailConfigPage *page,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *simple;
-
- g_return_val_if_fail (
- g_simple_async_result_is_valid (
- result, G_OBJECT (page),
- mail_config_ews_delegates_page_submit), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
+ g_return_val_if_fail (g_task_is_valid (result, page), FALSE);
- /* Assume success unless a GError is set. */
- return !g_simple_async_result_propagate_error (simple, error);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static gint
@@ -1451,7 +1376,7 @@ mail_config_ews_delegates_page_try_credentials_sync (EEwsConnection *connection,
async_context->page->priv->orig_delegates = g_slist_sort (delegates, sort_by_display_name_cb);
g_mutex_unlock (&async_context->page->priv->delegates_lock);
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
+ } else if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
result = E_SOURCE_AUTHENTICATION_REJECTED;
g_clear_object (&async_context->page->priv->connection);
g_error_free (local_error);
diff --git a/src/EWS/evolution/e-mail-config-ews-oal-combo-box.c
b/src/EWS/evolution/e-mail-config-ews-oal-combo-box.c
index f2c2f3f4..134ba31e 100644
--- a/src/EWS/evolution/e-mail-config-ews-oal-combo-box.c
+++ b/src/EWS/evolution/e-mail-config-ews-oal-combo-box.c
@@ -219,7 +219,7 @@ mail_config_ews_aol_combo_box_update_try_credentials_sync (EEwsConnection *conne
combo_box->priv->oal_items = oal_items;
g_mutex_unlock (&combo_box->priv->oal_items_lock);
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
+ } else if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
result = E_SOURCE_AUTHENTICATION_REJECTED;
g_error_free (local_error);
diff --git a/src/EWS/evolution/e-mail-config-ews-ooo-page.c b/src/EWS/evolution/e-mail-config-ews-ooo-page.c
index 44fd525f..fa853c81 100644
--- a/src/EWS/evolution/e-mail-config-ews-ooo-page.c
+++ b/src/EWS/evolution/e-mail-config-ews-ooo-page.c
@@ -767,7 +767,7 @@ mail_config_ews_ooo_page_try_credentials_sync (EEwsConnection *connection,
page->priv->changed = FALSE;
g_mutex_unlock (&page->priv->oof_settings_lock);
- } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
+ } else if (g_error_matches (local_error, E_SOUP_SESSION_ERROR, SOUP_STATUS_UNAUTHORIZED)) {
result = E_SOURCE_AUTHENTICATION_REJECTED;
g_error_free (local_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]