diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/mail-display.c | 66 | ||||
-rw-r--r-- | mail/mail-format.c | 97 |
3 files changed, 40 insertions, 129 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 09e7c657d4..46fc4f8027 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2001-12-14 Jeffrey Stedfast <fejj@ximian.com> + + * mail-format.c (try_inline_pgp): + (try_inline_pgp_sig): Start reiplementing The Right Way and not + danw's fucking half-assed kludge that doesn't work. + 2001-12-12 Jeffrey Stedfast <fejj@ximian.com> * mail-config.c (mail_config_set_new_mail_notification_command): diff --git a/mail/mail-display.c b/mail/mail-display.c index 3111e11922..5cb516df6a 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -71,7 +71,7 @@ struct _PixbufLoader { }; static GHashTable *thumbnail_cache = NULL; -static gchar *save_pathname = NULL; /* preserves last directory in save dialog */ +static char *save_pathname = NULL; /* preserves last directory in save dialog */ /*----------------------------------------------------------------------* * Callbacks @@ -126,7 +126,7 @@ make_safe_filename (const char *prefix,CamelMimePart *part) { const char *name = NULL; char *safe, *p; - + if (part) { name = camel_mime_part_get_filename (part); } @@ -135,7 +135,7 @@ make_safe_filename (const char *prefix,CamelMimePart *part) /* This is a filename. Translators take note. */ name = _("attachment"); } - + p = strrchr (name, '/'); if (p) safe = g_strdup_printf ("%s%s", prefix, p); @@ -154,24 +154,23 @@ save_data_cb (GtkWidget *widget, gpointer user_data) { GtkFileSelection *file_select = (GtkFileSelection *) gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_SELECTION); - gchar *p; - + char *p; + /* uh, this doesn't really feel right, but i dont know what to do better */ gtk_widget_hide (GTK_WIDGET (file_select)); - write_data_to_file (user_data, - gtk_file_selection_get_filename (file_select), + write_data_to_file (user_data, gtk_file_selection_get_filename (file_select), FALSE); - + /* preserve the pathname */ - g_free(save_pathname); - save_pathname = g_strdup(gtk_file_selection_get_filename(file_select)); - if((p = strrchr(save_pathname, '/')) != NULL) + g_free (save_pathname); + save_pathname = g_strdup (gtk_file_selection_get_filename (file_select)); + if((p = strrchr (save_pathname, '/')) != NULL) p[0] = 0; else { - g_free(save_pathname); + g_free (save_pathname); save_pathname = NULL; } - + gtk_widget_destroy (GTK_WIDGET (file_select)); } @@ -1124,8 +1123,8 @@ struct _load_content_msg { GtkHTML *html; GtkHTMLStream *handle; - gint redisplay_counter; - gchar *url; + int redisplay_counter; + char *url; CamelMimeMessage *message; void (*callback)(MailDisplay *, gpointer); gpointer data; @@ -1285,7 +1284,7 @@ stream_write_or_redisplay_when_loaded (MailDisplay *md, void mail_display_stream_write_when_loaded (MailDisplay *md, gconstpointer key, - const gchar *url, + const char *url, void (*callback)(MailDisplay *, gpointer), GtkHTML *html, GtkHTMLStream *handle, @@ -1309,12 +1308,12 @@ mail_text_write (GtkHTML *html, GtkHTMLStream *stream, gboolean printing, const { guint flags; char *htmltext; - + flags = E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_SPACES; - - if (! printing) + + if (!printing) flags |= E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_ADDRESSES; - + if (mail_config_get_citation_highlight () && ! printing) flags |= E_TEXT_TO_HTML_MARK_CITATION; @@ -1351,7 +1350,7 @@ static void clear_data (CamelObject *object, gpointer event_data, gpointer user_data) { GData *data = user_data; - + g_datalist_clear (&data); } @@ -2065,10 +2064,10 @@ mail_display_new (void) GtkWidget *scroll, *html; GdkAtom clipboard_atom; HTMLTokenizer *tok; - + gtk_box_set_homogeneous (GTK_BOX (mail_display), FALSE); gtk_widget_show (GTK_WIDGET (mail_display)); - + scroll = e_scroll_frame_new (NULL, NULL); e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll), GTK_POLICY_AUTOMATIC, @@ -2076,36 +2075,36 @@ mail_display_new (void) e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scroll), GTK_SHADOW_IN); gtk_box_pack_start_defaults (GTK_BOX (mail_display), GTK_WIDGET (scroll)); gtk_widget_show (GTK_WIDGET (scroll)); - + html = gtk_html_new (); tok = e_searching_tokenizer_new (); html_engine_set_tokenizer (GTK_HTML (html)->engine, tok); gtk_object_unref (GTK_OBJECT (tok)); - + mail_display_initialize_gtkhtml (mail_display, GTK_HTML (html)); - + gtk_container_add (GTK_CONTAINER (scroll), html); gtk_widget_show (GTK_WIDGET (html)); - + gtk_signal_connect (GTK_OBJECT (mail_display->invisible), "selection_get", GTK_SIGNAL_FUNC (invisible_selection_get_callback), mail_display); gtk_signal_connect (GTK_OBJECT (mail_display->invisible), "selection_clear_event", GTK_SIGNAL_FUNC (invisible_selection_clear_event_callback), mail_display); - + gtk_selection_add_target (mail_display->invisible, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1); - + clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); if (clipboard_atom != GDK_NONE) gtk_selection_add_target (mail_display->invisible, clipboard_atom, GDK_SELECTION_TYPE_STRING, 1); - + mail_display->scroll = E_SCROLL_FRAME (scroll); mail_display->html = GTK_HTML (html); mail_display->last_active = NULL; mail_display->data = g_new0 (GData *, 1); g_datalist_init (mail_display->data); - + return GTK_WIDGET (mail_display); } @@ -2114,9 +2113,9 @@ mail_display_initialize_gtkhtml (MailDisplay *mail_display, GtkHTML *html) { gtk_html_set_default_content_type (GTK_HTML (html), "text/html; charset=utf-8"); - + gtk_html_set_editable (GTK_HTML (html), FALSE); - + gtk_signal_connect (GTK_OBJECT (html), "url_requested", GTK_SIGNAL_FUNC (on_url_requested), mail_display); @@ -2136,7 +2135,6 @@ mail_display_initialize_gtkhtml (MailDisplay *mail_display, GtkHTML *html) GTK_SIGNAL_FUNC (html_iframe_created), mail_display); gtk_signal_connect (GTK_OBJECT (html), "on_url", GTK_SIGNAL_FUNC (html_on_url), mail_display); - } diff --git a/mail/mail-format.c b/mail/mail-format.c index 2deda8565a..68b51e8265 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -1350,107 +1350,14 @@ static char * try_inline_pgp (char *start, CamelMimePart *mime_part, guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - CamelMimePart *part; - CamelMultipart *multipart; - char *end; - - end = strstr (start, "\n-----END PGP MESSAGE-----\n"); - if (!end) - return start; - - end += sizeof ("\n-----END PGP MESSAGE-----\n") - 1; - - multipart = camel_multipart_new (); - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), - "multipart/encrypted; " - "protocol=\"application/pgp-encrypted\"; " - "x-inline-pgp-hack=true"); - - part = fake_mime_part_from_data ("Version: 1\n", - sizeof ("Version: 1\n") - 1, - "application/pgp-encrypted", - offset + 1, md); - camel_multipart_add_part (multipart, part); - camel_object_unref (CAMEL_OBJECT (part)); - - part = fake_mime_part_from_data (start, end - start + 1, - "application/octet-stream", - offset, md); - camel_multipart_add_part (multipart, part); - camel_object_unref (CAMEL_OBJECT (part)); - - part = camel_mime_part_new (); - camel_medium_set_content_object (CAMEL_MEDIUM (part), - CAMEL_DATA_WRAPPER (multipart)); - - camel_object_hook_event (CAMEL_OBJECT (md->current_message), - "finalize", destroy_part, part); - - write_hr (html, stream); - format_mime_part (part, md, html, stream); - - return end; + return start; } static char * try_inline_pgp_sig (char *start, CamelMimePart *mime_part, guint offset, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) { - CamelMimePart *part; - CamelMultipart *multipart; - char *msg_start, *msg_end, *sig_start, *sig_end; - CamelContentType *type; - char *type_str; - - /* We know start points to "-----BEGIN PGP SIGNED MESSAGE-----\n" */ - msg_start = start + sizeof ("-----BEGIN PGP SIGNED MESSAGE-----\n") - 1; - /* Skip 'One or more "Hash" Armor Headers' followed by - * 'Exactly one empty line'. - */ - msg_start = strstr (msg_start, "\n\n"); - if (!msg_start) - return start; - msg_start += 2; - msg_end = strstr (msg_start, "\n-----BEGIN PGP SIGNATURE-----\n"); - if (!msg_end) - return start; - - sig_start = msg_end; - sig_end = strstr (sig_start, "\n-----END PGP SIGNATURE-----\n"); - if (!sig_end) - return start; - sig_end += sizeof ("\n-----END PGP SIGNATURE-----\n") - 1; - - multipart = camel_multipart_new (); - camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), - "multipart/signed; micalg=pgp-sha1;" - "x-inline-pgp-hack=true"); - - type = camel_mime_part_get_content_type (mime_part); - type_str = header_content_type_format (type); - part = fake_mime_part_from_data (msg_start, msg_end - msg_start, - type_str, offset, md); - g_free (type_str); - camel_multipart_add_part (multipart, part); - camel_object_unref (CAMEL_OBJECT (part)); - - part = fake_mime_part_from_data (sig_start, sig_end - sig_start, - "application/pgp-signature", - offset + 1, md); - camel_multipart_add_part (multipart, part); - camel_object_unref (CAMEL_OBJECT (part)); - - part = camel_mime_part_new (); - camel_medium_set_content_object (CAMEL_MEDIUM (part), - CAMEL_DATA_WRAPPER (multipart)); - - camel_object_hook_event (CAMEL_OBJECT (md->current_message), - "finalize", destroy_part, part); - - write_hr (html, stream); - format_mime_part (part, md, html, stream); - - return sig_end; + return start; } static char * |