aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-10-31 08:26:58 +0800
committerDan Winship <danw@src.gnome.org>2001-10-31 08:26:58 +0800
commite7157ba8938ac2de32ad3c5f5b73db12ddb772c0 (patch)
tree873ddce80b85f860799ef8b1cfc660ebf6b73a80
parentc99cd2a0f9cc8f02b397960cbcd4faf05967702d (diff)
downloadgsoc2013-evolution-e7157ba8938ac2de32ad3c5f5b73db12ddb772c0.tar.gz
gsoc2013-evolution-e7157ba8938ac2de32ad3c5f5b73db12ddb772c0.tar.zst
gsoc2013-evolution-e7157ba8938ac2de32ad3c5f5b73db12ddb772c0.zip
New.
* Evolution-Composer.idl (setMultipartType): New. * evolution-composer.c (impl_Composer_set_multipart_type): Allow caller to specify a multipart/alternative rather than multipart/mixed. * e-msg-composer.c (build_message): Revert yesterday's changes. Add new ones for sending multipart/alternative. svn path=/trunk/; revision=14510
-rw-r--r--composer/ChangeLog11
-rw-r--r--composer/Evolution-Composer.idl26
-rw-r--r--composer/e-msg-composer.c39
-rw-r--r--composer/e-msg-composer.h2
-rw-r--r--composer/evolution-composer.c41
5 files changed, 72 insertions, 47 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 02ab55baaa..c849be32bc 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,14 @@
+2001-10-30 Dan Winship <danw@ximian.com>
+
+ * Evolution-Composer.idl (setMultipartType): New.
+
+ * evolution-composer.c (impl_Composer_set_multipart_type): Allow
+ caller to specify a multipart/alternative rather than
+ multipart/mixed.
+
+ * e-msg-composer.c (build_message): Revert yesterday's changes.
+ Add new ones for sending multipart/alternative.
+
2001-10-30 Larry Ewing <lewing@ximian.com>
* e-msg-composer.h: add dirty prototype.
diff --git a/composer/Evolution-Composer.idl b/composer/Evolution-Composer.idl
index c15597068a..dcf52b57e1 100644
--- a/composer/Evolution-Composer.idl
+++ b/composer/Evolution-Composer.idl
@@ -22,6 +22,11 @@ module Evolution {
typedef sequence<char> AttachmentData;
+ enum MultipartType {
+ MIXED,
+ ALTERNATIVE
+ };
+
/**
* setHeaders:
* @to: the "To" recipients
@@ -37,6 +42,27 @@ module Evolution {
in RecipientList bcc, in string subject);
/**
+ * setMultipartType:
+ * @type: a multipart subtype
+ *
+ * Sets the kind of multipart message that is being
+ * created.
+ *
+ * If @type is MIXED (the default), setBodyText()
+ * will create the body, and attachMIME() and
+ * attachData() will create attachments.
+ *
+ * If @type is ALTERNATIVE, setBodyText() will create
+ * text/plain alternative, and each following
+ * attachMIME() or attachData() call will create
+ * another alternative.
+ *
+ * Other values of @type are not currently supported,
+ * although "related" probably should be.
+ **/
+ void setMultipartType (in MultipartType type);
+
+ /**
* setBodyText:
* @body: the body
*
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e1b60a773e..740756e2b9 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -280,21 +280,6 @@ add_inlined_images (EMsgComposer *composer, CamelMultipart *multipart)
}
}
-static void
-copy_headers (CamelMedium *dest, CamelMedium *src)
-{
- CamelMediumHeader header;
- GArray *headers;
- int i;
-
- headers = camel_medium_get_headers (src);
- for (i = 0; i < headers->len; i++) {
- header = g_array_index (headers, CamelMediumHeader, i);
- camel_medium_set_header (dest, header.name, header.value);
- }
- camel_medium_free_headers (src, headers);
-}
-
/* This functions builds a CamelMimeMessage for the message that the user has
* composed in `composer'.
*/
@@ -314,7 +299,7 @@ build_message (EMsgComposer *composer)
CamelMultipart *body = NULL;
CamelMimePart *part;
CamelException ex;
- int i, num_attachments;
+ int i;
if (composer->persist_stream_interface == CORBA_OBJECT_NIL)
return NULL;
@@ -410,10 +395,14 @@ build_message (EMsgComposer *composer)
} else
current = plain;
- num_attachments = e_msg_composer_attachment_bar_get_num_attachments (attachment_bar);
- if (num_attachments) {
+ if (e_msg_composer_attachment_bar_get_num_attachments (attachment_bar)) {
CamelMultipart *multipart = camel_multipart_new ();
+ if (composer->is_alternative) {
+ camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart),
+ "multipart/alternative");
+ }
+
/* Generate a random boundary. */
camel_multipart_set_boundary (multipart, NULL);
@@ -426,18 +415,10 @@ build_message (EMsgComposer *composer)
camel_object_unref (CAMEL_OBJECT (part));
e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart, composer->charset);
-
- if (composer->no_body && num_attachments == 1) {
- part = camel_multipart_get_part (multipart, 1);
- current = camel_medium_get_content_object (CAMEL_MEDIUM (part));
- copy_headers (CAMEL_MEDIUM (new), CAMEL_MEDIUM (part));
- camel_medium_remove_header (CAMEL_MEDIUM (new), "Content-Disposition");
- camel_object_ref (CAMEL_OBJECT (current));
- camel_object_unref (CAMEL_OBJECT (multipart));
- } else
- current = CAMEL_DATA_WRAPPER (multipart);
+
+ current = CAMEL_DATA_WRAPPER (multipart);
}
-
+
if (composer->pgp_sign || composer->pgp_encrypt) {
part = camel_mime_part_new ();
camel_medium_set_content_object (CAMEL_MEDIUM (part), current);
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 395cf0a4ce..dab1db16bf 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -82,6 +82,7 @@ struct _EMsgComposer {
gboolean attachment_bar_visible : 1;
gboolean send_html : 1;
+ gboolean is_alternative: 1;
gboolean pgp_sign : 1;
gboolean pgp_encrypt : 1;
gboolean smime_sign : 1;
@@ -92,7 +93,6 @@ struct _EMsgComposer {
gboolean view_cc : 1;
gboolean view_subject : 1;
gboolean has_changed : 1;
- gboolean no_body : 1;
gboolean in_signature_insert : 1;
};
diff --git a/composer/evolution-composer.c b/composer/evolution-composer.c
index 289a8a3765..cf99f86e8b 100644
--- a/composer/evolution-composer.c
+++ b/composer/evolution-composer.c
@@ -98,6 +98,23 @@ impl_Composer_set_headers (PortableServer_Servant servant,
}
static void
+impl_Composer_set_multipart_type (PortableServer_Servant servant,
+ GNOME_Evolution_Composer_MultipartType type,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ if (type == GNOME_Evolution_Composer_ALTERNATIVE) {
+ composer->composer->is_alternative = TRUE;
+ composer->composer->send_html = FALSE;
+ }
+}
+
+static void
impl_Composer_set_body_text (PortableServer_Servant servant,
const CORBA_char *text,
CORBA_Environment *ev)
@@ -109,7 +126,6 @@ impl_Composer_set_body_text (PortableServer_Servant servant,
composer = EVOLUTION_COMPOSER (bonobo_object);
e_msg_composer_set_body_text (composer->composer, text);
- composer->composer->no_body = FALSE;
}
static void
@@ -206,12 +222,13 @@ evolution_composer_get_epv (void)
POA_GNOME_Evolution_Composer__epv *epv;
epv = g_new0 (POA_GNOME_Evolution_Composer__epv, 1);
- epv->setHeaders = impl_Composer_set_headers;
- epv->setBodyText = impl_Composer_set_body_text;
- epv->attachMIME = impl_Composer_attach_MIME;
- epv->attachData = impl_Composer_attach_data;
- epv->show = impl_Composer_show;
- epv->send = impl_Composer_send;
+ epv->setHeaders = impl_Composer_set_headers;
+ epv->setMultipartType = impl_Composer_set_multipart_type;
+ epv->setBodyText = impl_Composer_set_body_text;
+ epv->attachMIME = impl_Composer_attach_MIME;
+ epv->attachData = impl_Composer_attach_data;
+ epv->show = impl_Composer_show;
+ epv->send = impl_Composer_send;
return epv;
}
@@ -245,22 +262,12 @@ class_init (EvolutionComposerClass *klass)
}
static void
-unset_no_body (EMsgComposer *composer, gpointer user_data)
-{
- composer->no_body = FALSE;
-}
-
-static void
init (EvolutionComposer *composer)
{
const MailConfigAccount *account;
account = mail_config_get_default_account ();
composer->composer = e_msg_composer_new ();
- composer->composer->no_body = TRUE;
-
- gtk_signal_connect (GTK_OBJECT (composer->composer), "realize",
- GTK_SIGNAL_FUNC (unset_no_body), NULL);
gtk_signal_connect (GTK_OBJECT (composer->composer), "send",
GTK_SIGNAL_FUNC (send_cb), NULL);