[evolution-ews] Bug 758374 - Do not restrict/remove From address on message send
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug 758374 - Do not restrict/remove From address on message send
- Date: Wed, 7 Sep 2016 10:18:36 +0000 (UTC)
commit caa3abc71f1a7b90989ffac87f9bc4744d1cd313
Author: Milan Crha <mcrha redhat com>
Date: Wed Sep 7 12:18:14 2016 +0200
Bug 758374 - Do not restrict/remove From address on message send
src/camel/camel-ews-transport.c | 23 ++------------
src/utils/ews-camel-common.c | 63 ++++++++++++++++++++++++--------------
2 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/src/camel/camel-ews-transport.c b/src/camel/camel-ews-transport.c
index bd8274b..7688cf4 100644
--- a/src/camel/camel-ews-transport.c
+++ b/src/camel/camel-ews-transport.c
@@ -359,10 +359,10 @@ ews_send_to_sync (CamelTransport *transport,
g_object_unref (settings);
- used_from = camel_mime_message_get_from (message);
-
- if (!used_from && CAMEL_IS_INTERNET_ADDRESS (from))
+ if (CAMEL_IS_INTERNET_ADDRESS (from))
used_from = CAMEL_INTERNET_ADDRESS (from);
+ else
+ used_from = camel_mime_message_get_from (message);
if (!used_from || camel_address_length (CAMEL_ADDRESS (used_from)) == 0) {
g_set_error_literal (
@@ -379,7 +379,6 @@ ews_send_to_sync (CamelTransport *transport,
} else {
const gchar *used_email = NULL;
- gboolean addresses_match;
if (!camel_internet_address_get (used_from, 0, NULL, &used_email)) {
g_set_error_literal (
@@ -387,22 +386,6 @@ ews_send_to_sync (CamelTransport *transport,
_("Failed to read From address"));
goto exit;
}
-
- addresses_match =
- (ews_email != NULL) &&
- (used_email != NULL) &&
- (g_ascii_strcasecmp (ews_email, used_email) == 0);
-
- if (!addresses_match) {
- g_set_error (
- error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("Exchange server cannot send message as "
- "'%s', when the account was configured for "
- "address '%s'"),
- used_email ? used_email : "NULL",
- ews_email ? ews_email : "NULL");
- goto exit;
- }
}
cnc = ews_transport_ref_connection (CAMEL_EWS_TRANSPORT (service));
diff --git a/src/utils/ews-camel-common.c b/src/utils/ews-camel-common.c
index 498ac4a..eecce7f 100644
--- a/src/utils/ews-camel-common.c
+++ b/src/utils/ews-camel-common.c
@@ -31,10 +31,12 @@
#include "server/e-ews-item-change.h"
struct _create_mime_msg_data {
+ EEwsConnection *cnc;
CamelMimeMessage *message;
CamelMessageInfo *info;
CamelAddress *from;
CamelAddress *recipients;
+ gboolean is_send;
};
static void
@@ -262,6 +264,22 @@ create_mime_message_cb (ESoapMessage *msg,
}
}
+ if (create_data->cnc && create_data->is_send) {
+ CamelEwsSettings *settings;
+
+ settings = e_ews_connection_ref_settings (create_data->cnc);
+ if (settings) {
+ e_soap_message_start_element (msg, "Sender", NULL, NULL);
+
+ e_soap_message_start_element (msg, "Mailbox", NULL, NULL);
+ e_ews_message_write_string_parameter_with_attribute (msg, "EmailAddress", NULL,
camel_ews_settings_get_email (settings), NULL, NULL);
+ e_soap_message_end_element (msg); /* Mailbox */
+
+ e_soap_message_end_element (msg); /* Sender */
+ }
+ g_clear_object (&settings);
+ }
+
if (create_data->recipients) {
GHashTable *recip_to, *recip_cc, *recip_bcc;
@@ -280,6 +298,22 @@ create_mime_message_cb (ESoapMessage *msg,
g_hash_table_destroy (recip_bcc);
}
+ if (create_data->is_send && create_data->from && CAMEL_IS_INTERNET_ADDRESS (create_data->from)) {
+ const gchar *from_name = NULL, *from_email = NULL;
+
+ if (camel_internet_address_get (CAMEL_INTERNET_ADDRESS (create_data->from), 0, &from_name,
&from_email) && from_email) {
+ e_soap_message_start_element (msg, "From", NULL, NULL);
+
+ e_soap_message_start_element (msg, "Mailbox", NULL, NULL);
+ if (from_name && *from_name)
+ e_ews_message_write_string_parameter_with_attribute (msg, "Name", NULL,
from_name, NULL, NULL);
+ e_ews_message_write_string_parameter_with_attribute (msg, "EmailAddress", NULL,
from_email, NULL, NULL);
+ e_soap_message_end_element (msg); /* Mailbox */
+
+ e_soap_message_end_element (msg); /* From */
+ }
+ }
+
e_ews_message_write_string_parameter_with_attribute (
msg,
"IsRead",
@@ -310,27 +344,22 @@ camel_ews_utils_create_mime_message (EEwsConnection *cnc,
GSList *ids;
EEwsItem *item;
const EwsId *ewsid;
- gchar *restore_from = NULL;
gboolean res;
create_data = g_new0 (struct _create_mime_msg_data, 1);
+ create_data->cnc = cnc;
create_data->message = message;
create_data->info = info;
create_data->from = from;
create_data->recipients = recipients;
+ create_data->is_send = g_strcmp0 (disposition, "SendOnly") == 0 || g_strcmp0 (disposition,
"SendAndSaveCopy") == 0;
- if (g_strcmp0 (disposition, "SendOnly") == 0 ||
- g_strcmp0 (disposition, "SendAndSaveCopy") == 0) {
- struct _camel_header_raw *header;
+ if (create_data->is_send && !create_data->from) {
+ CamelInternetAddress *address = camel_mime_message_get_from (message);
- for (header = CAMEL_MIME_PART (message)->headers; header; header = header->next) {
- if (header->name && g_ascii_strcasecmp (header->name, "From") == 0) {
- restore_from = header->value;
- header->value = g_strdup ("");
- break;
- }
- }
+ if (address)
+ create_data->from = CAMEL_ADDRESS (address);
}
res = e_ews_connection_create_items_sync (
@@ -339,18 +368,6 @@ camel_ews_utils_create_mime_message (EEwsConnection *cnc,
create_mime_message_cb, create_data,
&ids, cancellable, error);
- if (restore_from) {
- struct _camel_header_raw *header;
-
- for (header = CAMEL_MIME_PART (message)->headers; header; header = header->next) {
- if (header->name && g_ascii_strcasecmp (header->name, "From") == 0) {
- g_free (header->value);
- header->value = restore_from;
- break;
- }
- }
- }
-
if (!res || (!itemid && !changekey))
return res;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]