aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Ewing <lewing@ximian.com>2001-10-11 04:35:33 +0800
committerLarry Ewing <lewing@src.gnome.org>2001-10-11 04:35:33 +0800
commitfee8a6f66d94161fbf7cd2d181c5021ea6be6d7f (patch)
treecd5df27955aaff2f325f47b323d75a19009a9e4e
parent44f3c6d906ce7d69637b5bd5ac82059f8c0c0ab8 (diff)
downloadgsoc2013-evolution-fee8a6f66d94161fbf7cd2d181c5021ea6be6d7f.tar.gz
gsoc2013-evolution-fee8a6f66d94161fbf7cd2d181c5021ea6be6d7f.tar.zst
gsoc2013-evolution-fee8a6f66d94161fbf7cd2d181c5021ea6be6d7f.zip
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
-rw-r--r--composer/ChangeLog13
-rw-r--r--composer/e-msg-composer.c120
-rw-r--r--composer/e-msg-composer.h3
3 files changed, 92 insertions, 44 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 9bd36cfd7e..bc9184ece5 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -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
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 4da1760c10..ce79fe1fb5 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -2434,6 +2434,29 @@ e_msg_composer_new (void)
}
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)
{
/* Find the text/html part and set the composer body to it's contents */
@@ -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);
@@ -2557,6 +2580,56 @@ is_special_header (const char *hdr_name)
}
/**
+ * 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;
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index e3cc8537ee..0f727d2065 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -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 */