diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/mail-config.c | 23 | ||||
-rw-r--r-- | mail/mail-config.h | 10 | ||||
-rw-r--r-- | mail/mail-format.c | 71 |
4 files changed, 102 insertions, 13 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 83451115b5..a6328d659b 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2002-04-10 Dan Winship <danw@ximian.com> + + * mail-config.c (config_read, mail_config_write, + mail_config_get_x_mailer_display_style, + mail_config_set_x_mailer_display_style): Handle the X-Mailer + display style. (There is currently no GUI for configuring this.) + + * mail-format.c (write_headers, write_xmailer_header): Show + X-Mailer/User-Agent (and Rupert's stamp of approval) as + appropriate. + 2002-04-09 Jeffrey Stedfast <fejj@ximian.com> * mail-account-gui.c (setup_service): Kludge around the brokeness diff --git a/mail/mail-config.c b/mail/mail-config.c index 6e2963ad22..1ecbbb1ff2 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -112,6 +112,7 @@ typedef struct { MailConfigForwardStyle default_forward_style; MailConfigReplyStyle default_reply_style; MailConfigDisplayStyle message_display_style; + MailConfigXMailerDisplayStyle x_mailer_display_style; char *default_charset; GHashTable *threaded_hash; @@ -946,6 +947,11 @@ config_read (void) config->notify_filename = bonobo_config_get_string ( config->db, "/Mail/Notify/new_mail_notification_sound_file", NULL); + /* X-Mailer header display */ + config->x_mailer_display_style = bonobo_config_get_long_with_default ( + config->db, "/Mail/Format/x_mailer_display_style", + MAIL_CONFIG_XMAILER_NONE, NULL); + /* last filesel dir */ config->last_filesel_dir = bonobo_config_get_string ( config->db, "/Mail/Filesel/last_filesel_dir", NULL); @@ -1310,6 +1316,11 @@ mail_config_write_on_exit (void) bonobo_config_set_string_wrapper (config->db, "/Mail/Notify/new_mail_notification_sound_file", config->notify_filename, NULL); + /* X-Mailer Display */ + bonobo_config_set_long (config->db, + "/Mail/Format/x_mailer_display_style", + config->x_mailer_display_style, NULL); + /* last filesel dir */ bonobo_config_set_string_wrapper (config->db, "/Mail/Filesel/last_filesel_dir", config->last_filesel_dir, NULL); @@ -2132,6 +2143,18 @@ mail_config_set_new_mail_notify_sound_file (const char *filename) config->notify_filename = g_strdup (filename); } +MailConfigXMailerDisplayStyle +mail_config_get_x_mailer_display_style (void) +{ + return config->x_mailer_display_style; +} + +void +mail_config_set_x_mailer_display_style (MailConfigXMailerDisplayStyle style) +{ + config->x_mailer_display_style = style; +} + const char * mail_config_get_label_name (int label) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 917924d025..4d34374d9a 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -114,6 +114,13 @@ typedef enum { MAIL_CONFIG_NOTIFY_PLAY_SOUND, } MailConfigNewMailNotify; +typedef enum { + MAIL_CONFIG_XMAILER_NONE = 0, + MAIL_CONFIG_XMAILER_EVO = 1, + MAIL_CONFIG_XMAILER_OTHER = 2, + MAIL_CONFIG_XMAILER_RUPERT_APPROVED = 4 +} MailConfigXMailerDisplayStyle; + typedef struct { char *name; guint32 color; @@ -234,6 +241,9 @@ void mail_config_set_new_mail_notify (MailConfigNewMailNotify const char *mail_config_get_new_mail_notify_sound_file (void); void mail_config_set_new_mail_notify_sound_file (const char *filename); +MailConfigXMailerDisplayStyle mail_config_get_x_mailer_display_style (void); +void mail_config_set_x_mailer_display_style (MailConfigXMailerDisplayStyle style); + const char *mail_config_get_default_charset (void); void mail_config_set_default_charset (const char *charset); diff --git a/mail/mail-format.c b/mail/mail-format.c index d0f5da6757..604740793c 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -895,15 +895,39 @@ write_default_header(CamelMimeMessage *message, MailDisplay *md, } } +static gboolean +write_xmailer_header (CamelMimeMessage *message, MailDisplay *md, + GtkHTML *html, GtkHTMLStream *stream, + MailConfigXMailerDisplayStyle xm) +{ + const char *xmailer, *evolution; + + xmailer = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Mailer"); + if (!xmailer) { + xmailer = camel_medium_get_header (CAMEL_MEDIUM (message), "User-Agent"); + if (!xmailer) + return FALSE; + } + + evolution = strstr (xmailer, "Evolution"); + if ((xm & MAIL_CONFIG_XMAILER_OTHER) || + (evolution && (xm & MAIL_CONFIG_XMAILER_EVO))) + write_text_header (_("Mailer"), xmailer, WRITE_BOLD, html, stream); + + return evolution != NULL && (xm & MAIL_CONFIG_XMAILER_RUPERT_APPROVED); +} + #define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3)) static void write_headers (CamelMimeMessage *message, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { + MailConfigXMailerDisplayStyle xm = mail_config_get_x_mailer_display_style (); gboolean full = (md->display_style == MAIL_CONFIG_DISPLAY_FULL_HEADERS); char bgcolor[7], fontcolor[7]; GtkStyle *style = NULL; + gboolean evo_icon = FALSE; int i; /* My favorite thing to do... muck around with colors so we respect people's stupid themes. @@ -940,16 +964,20 @@ write_headers (CamelMimeMessage *message, MailDisplay *md, strcpy (fontcolor, "000000"); } - gtk_html_stream_printf (stream, - "<table width=\"100%%\" cellpadding=0 cellspacing=0>" - "<tr><td colspan=3 height=10><table height=10 cellpadding=0 cellspacing=0>" - "<tr><td></td></tr></table></td></tr>" - "<tr><td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>" - "<td width=\"100%%\"><font color=\"#%s\">" - "<table bgcolor=\"#000000\" width=\"100%%\" " - "cellspacing=0 cellpadding=1><tr><td>" - "<table bgcolor=\"#%s\" width=\"100%%\" cellpadding=0 cellspacing=0>" - "<tr><td><table>\n", fontcolor, bgcolor); + gtk_html_stream_printf ( + stream, + "<table width=\"100%%\" cellpadding=0 cellspacing=0>" + /* Top margin */ + "<tr><td colspan=3 height=10><table height=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr>" + /* Left margin */ + "<tr><td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>" + /* Black border */ + "<td width=\"100%%\"><table bgcolor=\"#000000\" width=\"100%%\" cellspacing=0 cellpadding=1>" + /* Main header box */ + "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" cellpadding=0 cellspacing=0>" + /* Internal header table */ + "<tr valign=top><td><table><font color=\"#%s\">\n", + bgcolor, fontcolor); if (full) { struct _header_raw *header; @@ -975,12 +1003,29 @@ write_headers (CamelMimeMessage *message, MailDisplay *md, } else { for (i=0;i<sizeof(default_headers)/sizeof(default_headers[0]);i++) write_default_header(message, md, html, stream, i, 0); + if (xm != MAIL_CONFIG_XMAILER_NONE) + evo_icon = write_xmailer_header(message, md, html, stream, xm); } + /* Close off the internal header table */ + mail_html_write (html, stream, "</font></table></td>"); + + if (!md->printing && evo_icon) { + gtk_html_stream_printf (stream, + "<td align=right><table><tr><td width=16>" + "<img src=\"%s\">" + "</td></tr></table></td>", + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/monkey-16.png")); + } + mail_html_write (html, stream, - "</table></td></tr></table></td></tr></table></font></td>" - "<td><table width=10 cellpadding=0 cellspacing=0><tr><td>" - "</td></tr></table></td></tr></table>\n"); + /* Main header box */ + "</tr></table>" + /* Black border */ + "</td></tr></table></td>" + /* Right margin */ + "<td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td>" + "</tr></table>\n"); } static void |