add prototype.

2001-10-10  Larry Ewing  <lewing@ximian.com>

	* e-msg-composer.h: add prototype.

	* e-msg-composer.c (e_msg_composer_add_message_attachments): new
	function to copy attachments from the a message to a composer.
	(e_msg_composer_set_pending_body): make simple function to
	abstract this.
	(e_msg_composer_apply_pending_body): apply the pending body to
	the composer.
	(e_msg_composer_new_with_message): use
	e_msg_composer_add_message_attachments to copy attachments.

svn path=/trunk/; revision=13563
This commit is contained in:
Larry Ewing
2001-10-10 20:35:33 +00:00
committed by Larry Ewing
parent 44f3c6d906
commit fee8a6f66d
3 changed files with 92 additions and 44 deletions

View File

@ -1,3 +1,16 @@
2001-10-10 Larry Ewing <lewing@ximian.com>
* e-msg-composer.h: add prototype.
* e-msg-composer.c (e_msg_composer_add_message_attachments): new
function to copy attachments from the a message to a composer.
(e_msg_composer_set_pending_body): make simple function to
abstract this.
(e_msg_composer_apply_pending_body): apply the pending body to
the composer.
(e_msg_composer_new_with_message): use
e_msg_composer_add_message_attachments to copy attachments.
2001-10-09 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment-bar.c (add_from_file): If the

View File

@ -2433,6 +2433,29 @@ e_msg_composer_new (void)
return new;
}
static void
e_msg_composer_set_pending_body (EMsgComposer *composer, char *text)
{
char *old;
old = gtk_object_get_data (GTK_OBJECT (composer), "body:text");
g_free (old);
gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
}
static void
e_msg_composer_apply_pending_body (EMsgComposer *composer)
{
char *body;
body = gtk_object_get_data (GTK_OBJECT (composer), "body:text");
if (body) {
e_msg_composer_set_body_text (composer, body);
gtk_object_set_data (GTK_OBJECT (composer), "body:text", NULL);
g_free (body);
}
}
static void
handle_multipart_alternative (EMsgComposer *composer, CamelMultipart *multipart)
{
@ -2456,7 +2479,7 @@ handle_multipart_alternative (EMsgComposer *composer, CamelMultipart *multipart)
text = mail_get_message_body (contents, FALSE, FALSE);
if (text)
gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
e_msg_composer_set_pending_body (composer, text);
return;
}
@ -2504,7 +2527,7 @@ handle_multipart (EMsgComposer *composer, CamelMultipart *multipart, int depth)
text = mail_get_message_body (contents, FALSE, FALSE);
if (text)
gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
e_msg_composer_set_pending_body (composer, text);
} else {
/* this is a leaf of the tree, so attach it */
e_msg_composer_attach (composer, mime_part);
@ -2556,6 +2579,56 @@ is_special_header (const char *hdr_name)
return FALSE;
}
/**
* e_msg_composer_add_message_attachments:
* @composer: the composer to add the attachments to.
* @msg: the source message to copy the attachments from.
*
* Walk through all the mime parts in @msg and add them to the composer
* specified in @composer.
*/
void
e_msg_composer_add_message_attachments (EMsgComposer *composer, CamelMimeMessage *msg)
{
CamelContentType *content_type;
content_type = camel_mime_part_get_content_type (CAMEL_MIME_PART (msg));
if (header_content_type_is (content_type, "multipart", "alternative")) {
/* multipart/alternative contains the text/plain and text/html versions of the message body */
CamelDataWrapper *wrapper;
CamelMultipart *multipart;
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (CAMEL_MIME_PART (msg)));
multipart = CAMEL_MULTIPART (wrapper);
handle_multipart_alternative (composer, multipart);
} else if (header_content_type_is (content_type, "multipart", "*")) {
/* there must be attachments... */
CamelDataWrapper *wrapper;
CamelMultipart *multipart;
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (CAMEL_MIME_PART (msg)));
multipart = CAMEL_MULTIPART (wrapper);
handle_multipart (composer, multipart, 0);
} else {
/* We either have a text/plain or a text/html part */
CamelDataWrapper *contents;
char *text;
contents = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
text = mail_get_message_body (contents, FALSE, FALSE);
if (text)
e_msg_composer_set_pending_body (composer, text);
}
/* We wait until now to set the body text because we need to ensure that
* the attachment bar has all the attachments, before we request them.
*/
e_msg_composer_apply_pending_body (composer);
}
/**
* e_msg_composer_new_with_message:
* @msg: The message to use as the source
@ -2571,8 +2644,6 @@ e_msg_composer_new_with_message (CamelMimeMessage *msg)
GList *To = NULL, *Cc = NULL, *Bcc = NULL;
EDestination **Tov, **Ccv, **Bccv;
const char *format, *subject, *account_name;
char *body;
CamelContentType *content_type;
struct _header_raw *headers;
EMsgComposer *new;
XEvolution *xev;
@ -2673,46 +2744,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *msg)
headers = headers->next;
}
content_type = camel_mime_part_get_content_type (CAMEL_MIME_PART (msg));
if (header_content_type_is (content_type, "multipart", "alternative")) {
/* multipart/alternative contains the text/plain and text/html versions of the message body */
CamelDataWrapper *wrapper;
CamelMultipart *multipart;
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (CAMEL_MIME_PART (msg)));
multipart = CAMEL_MULTIPART (wrapper);
handle_multipart_alternative (new, multipart);
} else if (header_content_type_is (content_type, "multipart", "*")) {
/* there must be attachments... */
CamelDataWrapper *wrapper;
CamelMultipart *multipart;
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (CAMEL_MIME_PART (msg)));
multipart = CAMEL_MULTIPART (wrapper);
handle_multipart (new, multipart, 0);
} else {
/* We either have a text/plain or a text/html part */
CamelDataWrapper *contents;
char *text;
contents = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
text = mail_get_message_body (contents, FALSE, FALSE);
if (text)
gtk_object_set_data (GTK_OBJECT (new), "body:text", text);
}
/* We wait until now to set the body text because we need to ensure that
* the attachment bar has all the attachments, before we request them.
*/
body = gtk_object_get_data (GTK_OBJECT (new), "body:text");
if (body) {
e_msg_composer_set_body_text (new, body);
gtk_object_set_data (GTK_OBJECT (new), "body:text", NULL);
g_free (body);
}
e_msg_composer_add_message_attachments (new, msg);
return new;
}

View File

@ -172,6 +172,9 @@ gboolean e_msg_composer_get_smime_encrypt (EMsgComposer *compo
gchar * e_msg_composer_get_sig_file_content (const char *sigfile,
gboolean in_html);
void e_msg_composer_add_message_attachments (EMsgComposer *composer,
CamelMimeMessage *msg);
#ifdef __cplusplus
}
#endif /* __cplusplus */