[evolution-ews/gnome-3-2] Bug #664749 - Cannot send message "Service not connected" (cherry picked from commit 546b2d73fb72a75
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-2] Bug #664749 - Cannot send message "Service not connected" (cherry picked from commit 546b2d73fb72a75
- Date: Tue, 19 Jun 2012 22:43:09 +0000 (UTC)
commit 062779d120656752987644b80e36c4fe8c56c004
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 9 14:12:44 2012 +0100
Bug #664749 - Cannot send message "Service not connected"
(cherry picked from commit 546b2d73fb72a75d54cd035bda3567247f78a67a)
src/camel/camel-ews-transport.c | 34 ++++++++++++++++++++++++++++++++++
src/utils/ews-camel-common.c | 26 ++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/src/camel/camel-ews-transport.c b/src/camel/camel-ews-transport.c
index b3797d4..9ba2bc8 100644
--- a/src/camel/camel-ews-transport.c
+++ b/src/camel/camel-ews-transport.c
@@ -72,6 +72,7 @@ ews_send_to_sync (CamelTransport *transport,
GError **error)
{
CamelService *service;
+ CamelInternetAddress *used_from;
EEwsConnection *cnc;
const gchar *host_url;
CamelURL *url;
@@ -81,6 +82,38 @@ ews_send_to_sync (CamelTransport *transport,
url = camel_service_get_camel_url (service);
host_url = camel_url_get_param (url, "hosturl");
+ used_from = camel_mime_message_get_from (message);
+
+ if (!used_from && CAMEL_IS_INTERNET_ADDRESS (from))
+ used_from = CAMEL_INTERNET_ADDRESS (from);
+
+ if (!used_from || camel_address_length (CAMEL_ADDRESS (used_from)) == 0) {
+ g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Cannot send message with no From address"));
+ return FALSE;
+ } else if (camel_address_length (CAMEL_ADDRESS (used_from)) > 1) {
+ g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Exchange server cannot send message with multiple From addresses"));
+ return FALSE;
+ } else {
+ const gchar *ews_email = NULL, *used_email = NULL;
+
+ ews_email = camel_ews_settings_get_email (settings);
+ if (!camel_internet_address_get (used_from, 0, NULL, &used_email)) {
+ g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ _("Failed to read From address"));
+ return FALSE;
+ }
+
+ if (!ews_email || !used_email || g_ascii_strcasecmp (ews_email, used_email) != 0) {
+ 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");
+ return FALSE;
+ }
+ }
+
cnc = e_ews_connection_find (host_url, url->user);
if (!cnc) {
g_set_error (error, CAMEL_SERVICE_ERROR,
@@ -104,6 +137,7 @@ camel_ews_transport_class_init (CamelEwsTransportClass *class)
CamelTransportClass *transport_class;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_EWS_SETTINGS;
service_class->connect_sync = ews_transport_connect_sync;
service_class->get_name = ews_transport_get_name;
diff --git a/src/utils/ews-camel-common.c b/src/utils/ews-camel-common.c
index 121b2e8..58c210e 100644
--- a/src/utils/ews-camel-common.c
+++ b/src/utils/ews-camel-common.c
@@ -117,6 +117,7 @@ camel_ews_utils_create_mime_message (EEwsConnection *cnc, const gchar *dispositi
GSList *ids;
EEwsItem *item;
const EwsId *ewsid;
+ gchar *restore_from = NULL;
gboolean res;
create_data = g_new0 (struct _create_mime_msg_data, 1);
@@ -125,10 +126,35 @@ camel_ews_utils_create_mime_message (EEwsConnection *cnc, const gchar *dispositi
create_data->message_camel_flags = message_camel_flags;
create_data->from = from;
+ if (g_strcmp0 (disposition, "SendOnly") == 0) {
+ 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) {
+ restore_from = header->value;
+ header->value = g_strdup ("");
+ break;
+ }
+ }
+ }
+
res = e_ews_connection_create_items (cnc, EWS_PRIORITY_MEDIUM,
disposition, NULL, save_folder,
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]