aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-08-29 03:33:45 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-08-29 03:33:45 +0800
commit1e291c07c0b145d4d4183c92cd83867a61fd38ed (patch)
treec49da1220e1b1c3ec846cdbccf325904e267c0e4
parentfe8cf8c71d99d823d40bf09059e8312399d8e85e (diff)
downloadgsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar.gz
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar.bz2
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar.lz
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar.xz
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.tar.zst
gsoc2013-evolution-1e291c07c0b145d4d4183c92cd83867a61fd38ed.zip
Set the "From" address in the CamelMimeMessage. Also updated to use
2000-08-28 Jeffrey Stedfast <fejj@helixcode.com> * e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message): Set the "From" address in the CamelMimeMessage. Also updated to use get_subject to both make our lives easier and prepare for using UTF8 (e_msg_composer_hdrs_get_subject): Updated to behave similarly to get_from and return allocated memory (it will have to return allocated memory once it's converted to use UTF8 anyways) * e-msg-composer.c (setup_save_draft): Always set composer->send_html = TRUE so that formatting is preserved. svn path=/trunk/; revision=5084
-rw-r--r--composer/ChangeLog12
-rw-r--r--composer/e-msg-composer-hdrs.c57
-rw-r--r--composer/e-msg-composer-hdrs.h2
-rw-r--r--composer/e-msg-composer.c48
4 files changed, 74 insertions, 45 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 0d5311b76a..37373a545e 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,15 @@
+2000-08-28 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message): Set the
+ "From" address in the CamelMimeMessage. Also updated to use
+ get_subject to both make our lives easier and prepare for using UTF8
+ (e_msg_composer_hdrs_get_subject): Updated to behave similarly to
+ get_from and return allocated memory (it will have to return
+ allocated memory once it's converted to use UTF8 anyways)
+
+ * e-msg-composer.c (setup_save_draft): Always set
+ composer->send_html = TRUE so that formatting is preserved.
+
2000-08-24 Lauris Kaplinski <lauris@helixcode.com>
* e-msg-composer-address-entry.c: Use e_utf8 wrappers
diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c
index 31dbed9e39..96e2fded2e 100644
--- a/composer/e-msg-composer-hdrs.c
+++ b/composer/e-msg-composer-hdrs.c
@@ -518,18 +518,22 @@ void
e_msg_composer_hdrs_to_message (EMsgComposerHdrs *hdrs,
CamelMimeMessage *msg)
{
- const gchar *s;
-
+ gchar *subject;
+ gchar *from;
+
g_return_if_fail (hdrs != NULL);
g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs));
g_return_if_fail (msg != NULL);
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg));
-
- gtk_object_get(GTK_OBJECT(hdrs->priv->subject_entry),
- "text", &s,
- NULL);
- camel_mime_message_set_subject (msg, g_strdup (s));
-
+
+ subject = e_msg_composer_hdrs_get_subject (hdrs);
+ camel_mime_message_set_subject (msg, subject);
+ g_free (subject);
+
+ from = e_msg_composer_hdrs_get_from (hdrs);
+ camel_mime_message_set_from (msg, from);
+ g_free (from);
+
set_recipients (msg, hdrs->priv->to_entry, CAMEL_RECIPIENT_TYPE_TO);
set_recipients (msg, hdrs->priv->cc_entry, CAMEL_RECIPIENT_TYPE_CC);
set_recipients (msg, hdrs->priv->bcc_entry, CAMEL_RECIPIENT_TYPE_BCC);
@@ -563,7 +567,7 @@ e_msg_composer_hdrs_set_from (EMsgComposerHdrs *hdrs,
g_return_if_fail (hdrs != NULL);
g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs));
-
+
entry = GTK_ENTRY (GTK_COMBO (hdrs->priv->from_entry)->entry);
e_utf8_gtk_entry_set_text (entry, from);
}
@@ -606,14 +610,11 @@ e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs,
g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs));
g_return_if_fail (subject != NULL);
- gtk_object_set(GTK_OBJECT(hdrs->priv->subject_entry),
- "text", subject,
- NULL);
+ gtk_object_set (GTK_OBJECT (hdrs->priv->subject_entry),
+ "text", subject,
+ NULL);
}
-/*
- * Hmmm... this introduces possible memory leak, but syntax suggest allocated string
- */
char *
e_msg_composer_hdrs_get_from (EMsgComposerHdrs *hdrs)
{
@@ -629,9 +630,9 @@ e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs)
{
g_return_val_if_fail (hdrs != NULL, NULL);
g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
+
g_assert_not_reached ();
-
+
return NULL;
}
@@ -641,9 +642,9 @@ e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs)
{
g_return_val_if_fail (hdrs != NULL, NULL);
g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
+
g_assert_not_reached ();
-
+
return NULL;
}
@@ -653,25 +654,25 @@ e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs)
{
g_return_val_if_fail (hdrs != NULL, NULL);
g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
+
g_assert_not_reached ();
-
+
return NULL;
}
-const char *
+/* FIXME: This is just changed to return allooc'd mem to be consistant with get_from */
+char *
e_msg_composer_hdrs_get_subject (EMsgComposerHdrs *hdrs)
{
gchar *subject;
-
+
g_return_val_if_fail (hdrs != NULL, NULL);
g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
- gtk_object_get(GTK_OBJECT(hdrs->priv->subject_entry),
- "text", &subject,
- NULL);
- return subject;
+ gtk_object_get (GTK_OBJECT (hdrs->priv->subject_entry),
+ "text", &subject, NULL);
+
+ return g_strdup (subject);
}
diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h
index 78a478dbfa..a495fd853c 100644
--- a/composer/e-msg-composer-hdrs.h
+++ b/composer/e-msg-composer-hdrs.h
@@ -77,7 +77,7 @@ char *e_msg_composer_hdrs_get_from (EMsgComposerHdrs *hdrs);
GList *e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs);
GList *e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs);
GList *e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs);
-const char *e_msg_composer_hdrs_get_subject (EMsgComposerHdrs *hdrs);
+char *e_msg_composer_hdrs_get_subject (EMsgComposerHdrs *hdrs);
GtkWidget *e_msg_composer_hdrs_get_to_entry (EMsgComposerHdrs *hdrs);
GtkWidget *e_msg_composer_hdrs_get_cc_entry (EMsgComposerHdrs *hdrs);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 2d74775c7d..2090d985ac 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -208,23 +208,39 @@ build_message (EMsgComposer *composer)
{
EMsgComposerAttachmentBar *attachment_bar =
E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar);
+ MsgFormat type = MSG_FORMAT_ALTERNATIVE;
CamelMimeMessage *new;
CamelMultipart *body = NULL;
CamelMimePart *part;
+ gchar *from = NULL;
char *html = NULL, *plain = NULL, *fmt = NULL;
int i;
- MsgFormat type = MSG_FORMAT_ALTERNATIVE;
-
+
if (composer->persist_stream_interface == CORBA_OBJECT_NIL)
return NULL;
-
+
if (composer->send_html)
type = MSG_FORMAT_ALTERNATIVE;
else
type = MSG_FORMAT_PLAIN;
-
+
+ /* get and/or set the From field */
+ from = e_msg_composer_hdrs_get_from (E_MSG_COMPOSER_HDRS (composer->hdrs));
+ if (!from) {
+ const MailConfigIdentity *id = NULL;
+ CamelInternetAddress *ciaddr;
+
+ id = mail_config_get_default_identity ();
+ ciaddr = camel_internet_address_new ();
+ camel_internet_address_add (ciaddr, id->name, id->address);
+ from = camel_address_encode (CAMEL_ADDRESS (ciaddr));
+ e_msg_composer_hdrs_set_from (E_MSG_COMPOSER_HDRS (composer->hdrs), from);
+ camel_object_unref (CAMEL_OBJECT (ciaddr));
+ }
+ g_free (from);
+
new = camel_mime_message_new ();
-
+
e_msg_composer_hdrs_to_message (E_MSG_COMPOSER_HDRS (composer->hdrs), new);
for (i = 0; i < composer->extra_hdr_names->len; i++) {
camel_medium_add_header (CAMEL_MEDIUM (new),
@@ -238,13 +254,13 @@ build_message (EMsgComposer *composer)
if (type != MSG_FORMAT_PLAIN)
html = get_text (composer->persist_stream_interface, "text/html");
-
+
if (type == MSG_FORMAT_ALTERNATIVE) {
body = camel_multipart_new ();
camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (body),
"multipart/alternative");
camel_multipart_set_boundary (body, NULL);
-
+
part = camel_mime_part_new ();
camel_mime_part_set_content (part, fmt, strlen (fmt), "text/plain");
g_free (fmt);
@@ -257,13 +273,13 @@ build_message (EMsgComposer *composer)
camel_multipart_add_part (body, part);
camel_object_unref (CAMEL_OBJECT (part));
}
-
+
if (e_msg_composer_attachment_bar_get_num_attachments (attachment_bar)) {
CamelMultipart *multipart = camel_multipart_new ();
-
+
/* Generate a random boundary. */
camel_multipart_set_boundary (multipart, NULL);
-
+
part = camel_mime_part_new ();
switch (type) {
case MSG_FORMAT_ALTERNATIVE:
@@ -278,9 +294,9 @@ build_message (EMsgComposer *composer)
}
camel_multipart_add_part (multipart, part);
camel_object_unref (CAMEL_OBJECT (part));
-
+
e_msg_composer_attachment_bar_to_multipart (attachment_bar, multipart);
-
+
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (multipart));
camel_object_unref (CAMEL_OBJECT (multipart));
} else {
@@ -298,15 +314,14 @@ build_message (EMsgComposer *composer)
camel_object_unref (CAMEL_OBJECT (stream));
camel_data_wrapper_set_mime_type (cdw, "text/plain");
-
+
camel_medium_set_content_object (CAMEL_MEDIUM (new), CAMEL_DATA_WRAPPER (cdw));
camel_object_unref (CAMEL_OBJECT (cdw));
g_free (fmt);
break;
-
}
}
-
+
return new;
}
@@ -514,8 +529,9 @@ setup_save_draft (gpointer in_data, gpointer op_data, CamelException *ex)
save_draft_data_t *data = (save_draft_data_t *) op_data;
g_return_if_fail (input->composer != NULL);
-
+
/* initialize op_data */
+ input->composer->send_html = TRUE; /* always save drafts as HTML to keep formatting */
data->msg = e_msg_composer_get_message (input->composer);
data->info = g_new0 (CamelMessageInfo, 1);
data->info->flags = CAMEL_MESSAGE_DRAFT;