[evolution-mapi] Bug #610224 - Crash on a meeting forward notification mail



commit d4e8e1dd1d309acff386d4dcc28858e3b953fc58
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 17 13:34:54 2010 +0100

    Bug #610224 - Crash on a meeting forward notification mail

 .../exchange-mapi-account-listener.c               |    8 ++--
 .../exchange-mapi-account-setup.c                  |    2 +-
 src/camel/camel-mapi-folder.c                      |   38 +++++++++++--------
 3 files changed, 27 insertions(+), 21 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index a979be8..5ed27a5 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -607,7 +607,7 @@ mapi_account_removed (EAccountList *account_listener, EAccount *account)
 }
 
 static gboolean
-create_profile_entry (CamelURL *url)
+create_profile_entry (CamelURL *url, EAccount *account)
 {
 	gboolean status = FALSE;
 	guint8 attempts = 0; 
@@ -618,7 +618,7 @@ create_profile_entry (CamelURL *url)
 		key = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
 		password = e_passwords_get_password (EXCHANGE_MAPI_PASSWORD_COMPONENT, key);
 		if (!password) {
-			gboolean remember = FALSE;
+			gboolean remember = account && e_account_get_bool (account, E_ACCOUNT_SOURCE_SAVE_PASSWD);
 			gchar *title;
 
 			title = g_strdup_printf (_("Enter Password for %s %s"), url->user, url->host);
@@ -681,7 +681,7 @@ mapi_account_changed (EAccountList *account_listener, EAccount *account)
 
 	if (existing_account_info == NULL && isa_mapi_account) {
 		/* some account of other type is changed to MAPI */
-		if (create_profile_entry (new_url)) {
+		if (create_profile_entry (new_url, account)) {
 			/* Things are successful */
 			gchar *profname = NULL, *uri = NULL; 
 			ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
@@ -714,7 +714,7 @@ mapi_account_changed (EAccountList *account_listener, EAccount *account)
 		} else if (!mapi_camel_url_equal (old_url, new_url) || (existing_account_info->enabled != account->enabled)) {
 		/* Some or all of the account info changed OR the account has been moved from a disabled state to enabled state */
 			mapi_account_removed (account_listener, account);
-			if (create_profile_entry (new_url)) {
+			if (create_profile_entry (new_url, account)) {
 				/* Things are successful */
 				gchar *profname = NULL, *uri = NULL; 
 				ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.c b/src/account-setup-eplugin/exchange-mapi-account-setup.c
index beb88e5..306182e 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.c
@@ -208,7 +208,7 @@ validate_credentials (GtkWidget *widget, EConfig *config)
 	key = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
 	password = e_passwords_get_password (EXCHANGE_MAPI_PASSWORD_COMPONENT, key);
 	if (!password) {
-		gboolean remember = FALSE;
+		gboolean remember = e_account_get_bool (target_account->account, E_ACCOUNT_SOURCE_SAVE_PASSWD);
 		gchar *title;
 
 		title = g_strdup_printf (_("Enter Password for %s %s"), url->user, url->host);
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 8b21a92..8037e09 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1342,30 +1342,36 @@ fetch_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 		}
 	}
 
+	item->is_cal = FALSE;
 	if (g_str_has_prefix (msg_class, IPM_SCHEDULE_MEETING_PREFIX)) {
 		guint8 *appointment_body_str = (guint8 *) exchange_mapi_cal_util_camel_helper (item_data->properties, 
 											     item_data->streams, 
 											     item_data->recipients, item_data->attachments);
 
-		body = g_new0(ExchangeMAPIStream, 1);
-		body->proptag = PR_BODY;
-		body->value = g_byte_array_new ();
-		body->value = g_byte_array_append (body->value, appointment_body_str, strlen ((const char *)appointment_body_str));
+		if (appointment_body_str && *appointment_body_str) {
+			body = g_new0(ExchangeMAPIStream, 1);
+			body->proptag = PR_BODY;
+			body->value = g_byte_array_new ();
+			body->value = g_byte_array_append (body->value, appointment_body_str, strlen ((const char *)appointment_body_str));
 
-		item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
-
-		item->is_cal = TRUE;
+			item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
+			item->is_cal = TRUE;
+		}
 
 		g_free (appointment_body_str);
-	} else {
+	}
+
+	if (!item->is_cal) {
 		/* always prefer unicode version, as that can be properly read */
-		if (!((body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY_UNICODE)) || 
-		      (body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY))))
-			body = exchange_mapi_util_find_stream (item_data->streams, PR_HTML);
+		if (!(body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY_UNICODE)))
+			body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY);
 
-		item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
+		if (body)
+			item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
 
-		item->is_cal = FALSE;
+		body = exchange_mapi_util_find_stream (item_data->streams, PR_HTML);
+		if (body)
+			item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
 	}
 
 	if (delivery_date) {
@@ -1548,7 +1554,7 @@ mapi_mime_msg_body (MapiItem *item, const ExchangeMAPIStream *body)
 	CamelMimePart *part = camel_mime_part_new ();
 	camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_8BIT);
 	
-	if (body) {
+	if (body && body->value && body->value->len > 0) {
 		const gchar* type = NULL;
 		gchar *buff = NULL;
 
@@ -1570,7 +1576,7 @@ mapi_mime_msg_body (MapiItem *item, const ExchangeMAPIStream *body)
 
 		g_free (buff);
 	} else
-		camel_mime_part_set_content (part, "", strlen (""), "text/plain");
+		camel_mime_part_set_content (part, " ", strlen (" "), "text/plain");
 
 	return part;
 }
@@ -1779,7 +1785,7 @@ mapi_folder_item_to_msg( CamelFolder *folder, MapiItem *item, CamelException *ex
 		camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart_body),
 						  "multipart/mixed");
 		camel_multipart_set_boundary (multipart_body, NULL);
-		part = mapi_mime_msg_body (item, item->msg.body_parts->data);
+		part = mapi_mime_msg_body (item, item->msg.body_parts ? item->msg.body_parts->data : NULL);
 		camel_multipart_add_part (multipart_body, part);
 		camel_object_unref (part);
 	}



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