diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-11-07 20:33:01 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-11-07 20:33:01 +0800 |
commit | 25dcc0b87ac3ab29a4cc35ded91386558b4bc637 (patch) | |
tree | 302285e291ac4037ecf507720f46b0bd08716a00 /mail | |
parent | c70c4c35f3788bb210b6f01205e0bc71b4414c4f (diff) | |
download | gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar.gz gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar.bz2 gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar.lz gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar.xz gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.tar.zst gsoc2013-evolution-25dcc0b87ac3ab29a4cc35ded91386558b4bc637.zip |
God, I sure wish people would listen when i'm saying i'm changing and API.
2000-11-07 Not Zed <NotZed@HelixCode.com>
* mail-display.c (on_object_requested): God, I sure wish people
would listen when i'm saying i'm changing and API. I mean
I even mailed everyone and everything. Can't see any changelog
either.
2000-11-06 Not Zed <NotZed@HelixCode.com>
* mail-autofilter.c (rule_from_message): Updates for api changes.
* mail-tools.c (mail_tool_generate_forward_subject): Fixed for api
changes. Sigh, whoever wrote the multithread code of the mailer,
had little idea. You can't just lock for getting a const value,
until you are finished with it, cause the owner still owns it.
Fixed this too. Yuck, what a horrid forwarding format, can we
change this, or make it configurable? The mail headers show who
forwarded it, we dont need to duplicate it in that UGLY subject.
* mail-format.c (write_field_to_stream): Removed some jeffness.
dont g_strdup stuff we dont need to, and remove the
value_is_encoded thing since we can get the unencoded address
now.
(write_address): New function to write an address field.
(write_headers): Uses write_address to write addresses, cleaner,
fixed the god-awful unreadable indenting too.
(handle_text_plain): Use a 'smarter' printf format, so we dont
need to allocate and copy substrings unecessarily (esp since
they're about to be allocated any copied another few times
anyway *sigh*).
(write_field_to_stream): Commented out the isprint check, which
afaik serves no purpose.
(list_add_addresses): New function to build a list of
display-ready addresses. Although I think the composer then uses
these as internet-ready addresses. It should probably take a list
of CamelAddress's if thats what it wants.
(mail_generate_reply): Cleaned up the address list creation stuff
a heap, and fixes for camel api changes. Also fixed a small
memory leak as a side effect (fulladdr wasn't freed if it was the
same as the sender).
* mail-display.c (on_object_requested): Changed for interface
changes to the from address. I think passing the encoded
(internet version) of the address is right here.
svn path=/trunk/; revision=6475
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 45 | ||||
-rw-r--r-- | mail/mail-autofilter.c | 31 | ||||
-rw-r--r-- | mail/mail-display.c | 19 | ||||
-rw-r--r-- | mail/mail-format.c | 202 | ||||
-rw-r--r-- | mail/mail-tools.c | 24 |
5 files changed, 165 insertions, 156 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index a95eb87b4f..5639220852 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,48 @@ +2000-11-07 Not Zed <NotZed@HelixCode.com> + + * mail-display.c (on_object_requested): God, I sure wish people + would listen when i'm saying i'm changing and API. I mean + I even mailed everyone and everything. Can't see any changelog + either. + +2000-11-06 Not Zed <NotZed@HelixCode.com> + + * mail-autofilter.c (rule_from_message): Updates for api changes. + + * mail-tools.c (mail_tool_generate_forward_subject): Fixed for api + changes. Sigh, whoever wrote the multithread code of the mailer, + had little idea. You can't just lock for getting a const value, + until you are finished with it, cause the owner still owns it. + Fixed this too. Yuck, what a horrid forwarding format, can we + change this, or make it configurable? The mail headers show who + forwarded it, we dont need to duplicate it in that UGLY subject. + + * mail-format.c (write_field_to_stream): Removed some jeffness. + dont g_strdup stuff we dont need to, and remove the + value_is_encoded thing since we can get the unencoded address + now. + (write_address): New function to write an address field. + (write_headers): Uses write_address to write addresses, cleaner, + fixed the god-awful unreadable indenting too. + (handle_text_plain): Use a 'smarter' printf format, so we dont + need to allocate and copy substrings unecessarily (esp since + they're about to be allocated any copied another few times + anyway *sigh*). + (write_field_to_stream): Commented out the isprint check, which + afaik serves no purpose. + (list_add_addresses): New function to build a list of + display-ready addresses. Although I think the composer then uses + these as internet-ready addresses. It should probably take a list + of CamelAddress's if thats what it wants. + (mail_generate_reply): Cleaned up the address list creation stuff + a heap, and fixes for camel api changes. Also fixed a small + memory leak as a side effect (fulladdr wasn't freed if it was the + same as the sender). + + * mail-display.c (on_object_requested): Changed for interface + changes to the from address. I think passing the encoded + (internet version) of the address is right here. + 2000-11-06 Jeffrey Stedfast <fejj@helixcode.com> * folder-browser.c (on_right_click): Move filter stuff into a diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index d4b537ab31..d1a1795f48 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -217,25 +217,20 @@ rule_from_message (FilterRule *rule, RuleContext *context, CamelMimeMessage *msg } /* should parse the from address into an internet address? */ if (flags & AUTO_FROM) { - struct _header_address *haddr, *scan; - char *name, *namestr; - - haddr = header_address_decode (msg->from); - scan = haddr; - while (scan) { - if (scan->type == HEADER_ADDRESS_NAME) { - rule_add_sender (context, rule, scan->v.addr); - if (scan->name && scan->name[0]) - name = scan->name; - else - name = scan->v.addr; - namestr = g_strdup_printf (_("Mail from %s"), name); - filter_rule_set_name (rule, namestr); - g_free (namestr); - } - scan = scan->next; + const CamelInternetAddress *from; + int i; + const char *name, *addr; + char *namestr; + + from = camel_mime_message_get_from(msg); + for (i=0;camel_internet_address_get(from, i, &name, &addr); i++) { + rule_add_sender(context, rule, addr); + if (name==NULL || name[0]==0) + name = addr; + namestr = g_strdup_printf(_("Mail from %s"), name); + filter_rule_set_name(rule, namestr); + g_free(namestr); } - header_address_unref (haddr); } if (flags & AUTO_TO) { addr = (CamelInternetAddress *)camel_mime_message_get_recipients (msg, CAMEL_RECIPIENT_TYPE_TO); diff --git a/mail/mail-display.c b/mail/mail-display.c index 6ac113414b..350d1e1772 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -471,7 +471,6 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) BonoboStream *bstream; BonoboControlFrame *control_frame; Bonobo_PropertyBag prop_bag; - const char *from_address; char *cid; cid = eb->classid; @@ -554,24 +553,16 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) the iTip control, and it needs only the From email address, but perhaps in the future we can generalize this section of code to pass a bunch of useful things to all embedded controls. */ - - CamelInternetAddress *ia; - const char *addr; - const char *name; + const CamelInternetAddress *from; + char *from_address; CORBA_exception_init (&ev); - ia = camel_internet_address_new (); - addr = camel_mime_message_get_from (md->current_message); - camel_address_decode (CAMEL_ADDRESS (ia), (const char *) addr); - - camel_internet_address_get (ia, 0, &name, &from_address); - + from = camel_mime_message_get_from (md->current_message); + from_address = camel_address_encode((CamelAddress *)from); bonobo_property_bag_client_set_value_string (prop_bag, "from_address", from_address, &ev); - - camel_object_unref (CAMEL_OBJECT (ia)); - + g_free(from_address); CORBA_exception_free (&ev); } } diff --git a/mail/mail-format.c b/mail/mail-format.c index bd9aee294b..e1109a09c1 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -540,80 +540,73 @@ call_handler_function (CamelMimePart *part, MailDisplay *md) return output; } +/* flags for write_field_to_stream */ +enum { + WRITE_BOLD=1, +}; + static void -write_field_to_stream (const char *description, const char *value, - gboolean value_is_encoded, gboolean bold, GtkHTML *html, - GtkHTMLStream *stream) +write_field_to_stream(const char *description, const char *value, int flags, GtkHTML *html, GtkHTMLStream *stream) { char *encoded_value; + int bold = (flags&WRITE_BOLD) == WRITE_BOLD; if (value) { - char *raw, *p; - - if (value_is_encoded) - raw = header_decode_string (value); - else - raw = g_strdup (value); - - encoded_value = e_text_to_html (raw, - E_TEXT_TO_HTML_CONVERT_NL | - E_TEXT_TO_HTML_CONVERT_URLS); - g_free (raw); + encoded_value = e_text_to_html (value, E_TEXT_TO_HTML_CONVERT_NL|E_TEXT_TO_HTML_CONVERT_URLS); +#if 0 /* I dont think this needs to be here anymore ... e_text_to_html should handle that anyway */ + char *p; for (p = encoded_value; *p; p++) { if (!isprint (*p)) *p = '?'; } +#endif } else encoded_value = ""; - mail_html_write (html, stream, - "<tr valign=top><%s align=right>%s</%s>" - "<td>%s</td></tr>", bold ? "th" : "td", - description, bold ? "th" : "td", encoded_value); + mail_html_write(html, stream, + "<tr valign=top><%s align=right>%s</%s>" + "<td>%s</td></tr>", bold ? "th" : "td", + description, bold ? "th" : "td", encoded_value); if (value) - g_free (encoded_value); + g_free(encoded_value); } static void -write_headers (CamelMimeMessage *message, MailDisplay *md) +write_address(MailDisplay *md, const CamelInternetAddress *addr, const char *name, int flags) { - const CamelInternetAddress *recipients; - const char *reply_to; char *string; + if (addr == NULL) + return; + + string = camel_address_format((CamelAddress *)addr); + if (string && string[0]) { + write_field_to_stream(name, string, flags, md->html, md->stream); + } + g_free(string); +} + + +static void +write_headers (CamelMimeMessage *message, MailDisplay *md) +{ mail_html_write (md->html, md->stream, "<table bgcolor=\"#EEEEEE\" width=\"100%%\" " "cellspacing=0 border=1>" "<tr><td><table>\n"); - write_field_to_stream (_("From:"), - camel_mime_message_get_from (message), - TRUE, TRUE, md->html, md->stream); + write_address(md, camel_mime_message_get_from(message), + _("From:"), WRITE_BOLD); + write_address(md, camel_mime_message_get_reply_to(message), + _("Reply-To:"), 0); + write_address(md, camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_TO), + _("To:"), WRITE_BOLD); + write_address(md, camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_CC), + _("Cc:"), WRITE_BOLD); - reply_to = camel_mime_message_get_reply_to (message); - if (reply_to) { - write_field_to_stream (_("Reply-To:"), reply_to, TRUE, FALSE, - md->html, md->stream); - } - - recipients = camel_mime_message_get_recipients ( - message, CAMEL_RECIPIENT_TYPE_TO); - string = camel_address_encode (CAMEL_ADDRESS (recipients)); - write_field_to_stream (_("To:"), string ? string : "", TRUE, TRUE, - md->html, md->stream); - g_free (string); - - recipients = camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_CC); - string = camel_address_encode(CAMEL_ADDRESS(recipients)); - if (string) { - write_field_to_stream (_("Cc:"), string, TRUE, TRUE, - md->html, md->stream); - } - g_free (string); - write_field_to_stream (_("Subject:"), camel_mime_message_get_subject (message), - FALSE, TRUE, md->html, md->stream); + TRUE, md->html, md->stream); mail_html_write (md->html, md->stream, "</table></td></tr></table></center><p>"); @@ -671,7 +664,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type, { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - char *text, *p, *start, *subtext; + char *text, *p, *start; GMimeContentField *type; const char *format; int i; @@ -701,10 +694,8 @@ handle_text_plain (CamelMimePart *part, const char *mime_type, /* Deal with special case */ if (start != p) { - subtext = g_strndup (p, start - p); - mail_text_write (md->html, md->stream, - "%s", subtext); - g_free (subtext); + /* the %.*s thing just grabs upto start-p chars; go read ANSI C */ + mail_text_write (md->html, md->stream, "%.*s", start-p, p); } p = text_specials[i].handler (start, md); if (p == start) { @@ -714,10 +705,7 @@ handle_text_plain (CamelMimePart *part, const char *mime_type, p = strchr (start, '\n'); if (!p++) break; - subtext = g_strndup (start, p - start); - mail_text_write (md->html, md->stream, - "%s", subtext); - g_free (subtext); + mail_text_write (md->html, md->stream, "%.*s", p-start, start); } else if (p) mail_html_write (md->html, md->stream, "<hr>"); } @@ -1625,17 +1613,45 @@ free_recipients (GList *list) g_list_free (list); } +static GList * +list_add_addresses(GList *list, const CamelInternetAddress *cia, const char *notme) +{ + int i; + const char *name, *addr; + char *full; + + for (i=0;camel_internet_address_get(cia, i, &name, &addr);i++) { + /* now, we format this, as if for display, but does the composer + then use it as a real address? If so, very broken. */ + /* we should probably pass around CamelAddresse's if thats what + we mean */ + full = camel_internet_address_format_address(name, addr); + + /* Here I'll check to see if the cc:'d address is the address + of the sender, and if so, don't add it to the cc: list; this + is to fix Bugzilla bug #455. */ + + if (notme && strcmp(addr, notme) == 0) + g_free(full); + else + list = g_list_append(list, full); + } + + return list; +} + EMsgComposer * mail_generate_reply (CamelMimeMessage *message, gboolean to_all) { CamelDataWrapper *contents; - char *text, *subject, *recipient; + char *text, *subject; EMsgComposer *composer; gboolean want_plain, is_html; - const char *repl_to, *message_id, *references; - GList *to, *cc; + const char *message_id, *references; + GList *to = NULL, *cc = NULL; MailConfigIdentity *id; gchar *sig_file = NULL; + const CamelInternetAddress *reply_to; id = mail_config_get_default_identity (); if (id) @@ -1699,64 +1715,20 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all) } /* Set the recipients */ - repl_to = camel_mime_message_get_reply_to (message); - if (!repl_to) - repl_to = camel_mime_message_get_from (message); - - recipient = header_decode_string (repl_to ? repl_to : ""); - to = g_list_append (NULL, (gpointer)recipient); + reply_to = camel_mime_message_get_reply_to(message); + if (!reply_to) + reply_to = camel_mime_message_get_from(message); + if (reply_to) + to = g_list_append(to, camel_address_format((CamelAddress *)reply_to)); if (to_all) { - const CamelInternetAddress *recip; - const char *name, *addr; - char *fulladdr; - int i; - - recip = camel_mime_message_get_recipients (message, - CAMEL_RECIPIENT_TYPE_TO); - i = 0; - cc = NULL; - while (camel_internet_address_get (recip, i++, &name, &addr)) { - if (name && *name) { - char *dname = header_decode_string (name); - - if (dname && *dname) - fulladdr = g_strdup_printf ("\"%s\" <%s>", dname, addr); - else - fulladdr = g_strdup (addr); - - g_free (dname); - } else - fulladdr = g_strdup (addr); - - /* Here I'll check to see if the cc:'d address is the address - of the sender, and if so, don't add it to the cc: list; this - is to fix Bugzilla bug #455. */ - - if (strcmp (addr, id->address) != 0) - cc = g_list_append (cc, fulladdr); - } - - recip = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); - i = 0; - while (camel_internet_address_get (recip, i++, &name, &addr)) { - if (name && *name) { - char *dname = header_decode_string (name); - - if (dname && *dname) - fulladdr = g_strdup_printf ("\"%s\" <%s>", dname, addr); - else - fulladdr = g_strdup (addr); - - g_free (dname); - } else - fulladdr = g_strdup (addr); - - if (strcmp (addr, id->address) != 0) - cc = g_list_append (cc, fulladdr); - } - } else - cc = NULL; + cc = list_add_addresses(cc, + camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_TO), + id->address); + cc = list_add_addresses(cc, + camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_CC), + id->address); + } /* Set the subject of the new message. */ subject = (char *)camel_mime_message_get_subject (message); diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 0ab7862200..25b353016e 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -345,25 +345,29 @@ mail_tool_set_uid_flags (CamelFolder *folder, const char *uid, guint32 mask, gui mail_tool_camel_lock_down (); } -gchar * +char * mail_tool_generate_forward_subject (CamelMimeMessage *msg) { - const gchar *from; - const gchar *subject; - gchar *fwd_subj; + const char *subject; + char *fwd_subj, *fromstr; + const CamelInternetAddress *from; + /* we need to lock around the whole function, as we are + only getting references to the message's data */ mail_tool_camel_lock_up(); - from = camel_mime_message_get_from (msg); - subject = camel_mime_message_get_subject (msg); - mail_tool_camel_lock_down(); + + from = camel_mime_message_get_from(msg); + subject = camel_mime_message_get_subject(msg); if (from) { + fromstr = camel_address_format((CamelAddress *)from); if (subject && *subject) { - fwd_subj = g_strdup_printf ("[%s] %s", from, subject); + fwd_subj = g_strdup_printf ("[%s] %s", fromstr, subject); } else { fwd_subj = g_strdup_printf (_("[%s] (forwarded message)"), - from); + fromstr); } + g_free(fromstr); } else { if (subject && *subject) { if (strncmp (subject, "Fwd: ", 5) == 0) @@ -373,6 +377,8 @@ mail_tool_generate_forward_subject (CamelMimeMessage *msg) fwd_subj = g_strdup (_("Fwd: (no subject)")); } + mail_tool_camel_lock_down(); + return fwd_subj; } |