[evolution/wip/gsettings] em_utils_reply_to_message(): Require a CamelMimeMessage.



commit f21da771776286769f390a6631a1a5fc2a675e76
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu May 12 16:57:37 2011 -0400

    em_utils_reply_to_message(): Require a CamelMimeMessage.
    
    No more fetching a message itself.  Oh, and stop unreffing the message.
    Those kinds of insane semantics are what lead to crashes.

 mail/e-mail-reader-utils.c               |    6 ++-
 mail/e-mail-reader.c                     |    7 ---
 mail/em-composer-utils.c                 |   74 ++++--------------------------
 mail/em-composer-utils.h                 |    4 +-
 modules/mail/e-mail-attachment-handler.c |   14 ++----
 5 files changed, 19 insertions(+), 86 deletions(-)
---
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 1da1a65..6ed50b1 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -612,16 +612,18 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 	g_object_unref (src_message);
 
 	em_utils_reply_to_message (
-		shell, folder, uid, new_message,
+		shell, new_message, folder, uid,
 		reply_type, reply_style, NULL);
 
+	g_object_unref (new_message);
+
 	g_free (selection);
 
 	return;
 
 whole_message:
 	em_utils_reply_to_message (
-		shell, folder, uid, src_message,
+		shell, src_message, folder, uid,
 		reply_type, reply_style, EM_FORMAT (formatter));
 }
 
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 315e6b9..673a5b2 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1122,9 +1122,6 @@ action_mail_reply_all_check (CamelFolder *folder,
 	if (!message)
 		return;
 
-	/* get_message_free () will unref the message, so we need to take an
-	   extra ref for e_mail_reader_reply_to_message () to own. */
-	g_object_ref (message);
 	to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
 	cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
 
@@ -1291,10 +1288,6 @@ action_mail_reply_sender_check (CamelFolder *folder,
 
 	munged_list_message = em_utils_is_munged_list_message (message);
 
-	/* get_message_free () will unref the message, so we need to take an
-	   extra ref for e_mail_reader_reply_to_message () to own. */
-	g_object_ref (message);
-
 	/* Don't do the "Are you sure you want to reply in private?" pop-up if
 	   it's a Reply-To: munged list message... unless we're ignoring munging */
 	if (ask_ignore_list_reply_to || !munged_list_message) {
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 654144b..a8208dc 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -2672,13 +2672,6 @@ composer_set_body (EMsgComposer *composer,
 	g_object_unref (client);
 }
 
-struct _reply_data {
-	EShell *shell;
-	EMFormat *source;
-	EMailReplyType reply_type;
-	EMailReplyStyle reply_style;
-};
-
 gchar *
 em_utils_construct_composer_text (CamelMimeMessage *message, EMFormat *source)
 {
@@ -2694,56 +2687,26 @@ em_utils_construct_composer_text (CamelMimeMessage *message, EMFormat *source)
 	return text;
 }
 
-static void
-reply_to_message (CamelFolder *folder,
-                  const gchar *uid,
-                  CamelMimeMessage *message,
-                  gpointer user_data)
-{
-	struct _reply_data *rd = user_data;
-
-	if (message != NULL) {
-		/* get_message_free() will also unref the message, so we need
-		   an extra ref for em_utils_reply_to_message () to drop. */
-		g_object_ref (message);
-		em_utils_reply_to_message (
-			rd->shell, folder, uid, message,
-			rd->reply_type, rd->reply_style, rd->source);
-	}
-
-	if (rd->shell != NULL)
-		g_object_unref (rd->shell);
-
-	if (rd->source != NULL)
-		g_object_unref (rd->source);
-
-	g_free (rd);
-}
-
 /**
  * em_utils_reply_to_message:
  * @shell: an #EShell
- * @folder: optional folder
- * @uid: optional uid
- * @message: message to reply to, optional
+ * @message: a #CamelMimeMessage
+ * @folder: a #CamelFolder, or %NULL
+ * @message_uid: the UID of @message, or %NULL
  * @type: the type of reply to create
  * @style: the reply style to use
  * @source: source to inherit view settings from
  *
  * Creates a new composer ready to reply to @message.
  *
- * If @message is NULL then @folder and @uid must be set to the
- * message to be replied to, it will be loaded asynchronously.
- *
- * If @message is non null, then it is used directly, @folder and @uid
- * may be supplied in order to update the message flags once it has
- * been replied to. Note that @message will be unreferenced on completion.
+ * @folder and @message_uid may be supplied in order to update the message
+ * flags once it has been replied to.
  **/
 EMsgComposer *
 em_utils_reply_to_message (EShell *shell,
-                           CamelFolder *folder,
-                           const gchar *uid,
                            CamelMimeMessage *message,
+                           CamelFolder *folder,
+                           const gchar *message_uid,
                            EMailReplyType type,
                            EMailReplyStyle style,
                            EMFormat *source)
@@ -2755,24 +2718,7 @@ em_utils_reply_to_message (EShell *shell,
 	guint32 flags;
 
 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
-
-	if (folder && uid && message == NULL) {
-		struct _reply_data *rd = g_malloc0 (sizeof (*rd));
-
-		rd->shell = g_object_ref (shell);
-		rd->reply_type = type;
-		rd->reply_style = style;
-		rd->source = source;
-		if (rd->source)
-			g_object_ref (rd->source);
-		mail_get_message (
-			folder, uid, reply_to_message,
-			rd, mail_msg_unordered_push);
-
-		return NULL;
-	}
-
-	g_return_val_if_fail (message != NULL, NULL);
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
 
 	to = camel_internet_address_new ();
 	cc = camel_internet_address_new ();
@@ -2818,15 +2764,13 @@ em_utils_reply_to_message (EShell *shell,
 
 	composer_set_body (composer, message, style, source);
 
-	g_object_unref (message);
-
 	if (folder != NULL) {
 		gchar *folder_uri;
 
 		folder_uri = e_mail_folder_uri_from_folder (folder);
 
 		e_msg_composer_set_source_headers (
-			composer, folder_uri, uid, flags);
+			composer, folder_uri, message_uid, flags);
 
 		g_free (folder_uri);
 	}
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 7a0d2d7..be76148 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -76,9 +76,9 @@ void		em_utils_get_reply_all		(CamelMimeMessage *message,
 						 CamelInternetAddress *cc,
 						 CamelNNTPAddress *postto);
 EMsgComposer *	em_utils_reply_to_message	(EShell *shell,
-						 CamelFolder *folder,
-						 const gchar *uid,
 						 CamelMimeMessage *message,
+						 CamelFolder *folder,
+						 const gchar *message_uid,
 						 EMailReplyType type,
 						 EMailReplyStyle style,
 						 EMFormat *source);
diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c
index a11515b..befac08 100644
--- a/modules/mail/e-mail-attachment-handler.c
+++ b/modules/mail/e-mail-attachment-handler.c
@@ -115,12 +115,9 @@ mail_attachment_handler_reply_all (GtkAction *action,
 	shell_settings = e_shell_get_shell_settings (priv->shell);
 	style = e_shell_settings_get_int (shell_settings, property_name);
 
-	/* em_utils_reply_to_message() unrefs 'message', thus ref it here */
-	g_object_ref (wrapper);
-
 	em_utils_reply_to_message (
-		priv->shell, NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
-		E_MAIL_REPLY_TO_ALL, style, NULL);
+		priv->shell, CAMEL_MIME_MESSAGE (wrapper),
+		NULL, NULL, E_MAIL_REPLY_TO_ALL, style, NULL);
 
 	g_list_foreach (selected, (GFunc) g_object_unref, NULL);
 	g_list_free (selected);
@@ -154,12 +151,9 @@ mail_attachment_handler_reply_sender (GtkAction *action,
 	shell_settings = e_shell_get_shell_settings (priv->shell);
 	style = e_shell_settings_get_int (shell_settings, property_name);
 
-	/* em_utils_reply_to_message() unrefs 'message', thus ref it here */
-	g_object_ref (wrapper);
-
 	em_utils_reply_to_message (
-		priv->shell, NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
-		E_MAIL_REPLY_TO_SENDER, style, NULL);
+		priv->shell, CAMEL_MIME_MESSAGE (wrapper),
+		NULL, NULL, E_MAIL_REPLY_TO_SENDER, style, NULL);
 
 	g_list_foreach (selected, (GFunc) g_object_unref, NULL);
 	g_list_free (selected);



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