diff options
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 45 | ||||
-rw-r--r-- | mail/em-format.c | 7 | ||||
-rw-r--r-- | mail/em-format.h | 5 |
4 files changed, 63 insertions, 5 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 34ac00bd34..cb97b0c42c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2004-01-05 Not Zed <NotZed@Ximian.com> + + ** See bug #50996. + + * em-format-html-display.c (efhd_find_handler): implement override + for unknown types, try bonobo handlers. + (efhd_bonobo_unknown): formathandler for bonobo objects. + + * em-format.c (em_format_find_handler): make virtual, rename to + emf_find_handler. + 2004-01-04 David Woodhouse <dwmw2@infradead.org> * em-format-html-display.c: Mail warning grammar typo fix. diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 57bbeee143..eaccf32e47 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -74,6 +74,7 @@ #include <e-util/e-dialog-utils.h> #if defined(HAVE_NSS) +#include <camel/camel-smime-context.h> #include "certificate-viewer.h" #include "e-cert-db.h" #endif @@ -123,6 +124,7 @@ static void efhd_iframe_created(GtkHTML *html, GtkHTML *iframe, EMFormatHTMLDisp /*static void efhd_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMFormatHTMLDisplay *efh); static gboolean efhd_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTMLDisplay *efh);*/ +static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type); static void efhd_format_clone(EMFormat *, CamelMedium *, EMFormat *); static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt); static void efhd_format_message(EMFormat *, CamelStream *, CamelMedium *); @@ -130,6 +132,9 @@ static void efhd_format_source(EMFormat *, CamelStream *, CamelMimePart *); static void efhd_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const char *, const EMFormatHandler *); static void efhd_complete(EMFormat *); +static gboolean efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); +static gboolean efhd_use_component(const char *mime_type); + static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); enum { @@ -140,7 +145,8 @@ enum { static guint efhd_signals[EFHD_LAST_SIGNAL] = { 0 }; - +/* EMFormatHandler's for bonobo objects */ +static GHashTable *efhd_bonobo_handlers; static EMFormatHTMLClass *efhd_parent; static void @@ -254,6 +260,7 @@ efhd_bool_accumulator(GSignalInvocationHint *ihint, GValue *out, const GValue *i static void efhd_class_init(GObjectClass *klass) { + ((EMFormatClass *)klass)->find_handler = efhd_find_handler; ((EMFormatClass *)klass)->format_clone = efhd_format_clone; ((EMFormatClass *)klass)->format_error = efhd_format_error; ((EMFormatClass *)klass)->format_message = efhd_format_message; @@ -302,6 +309,8 @@ em_format_html_display_get_type(void) }; efhd_parent = g_type_class_ref(em_format_html_get_type()); type = g_type_register_static(em_format_html_get_type(), "EMFormatHTMLDisplay", &info, 0); + + efhd_bonobo_handlers = g_hash_table_new(g_str_hash, g_str_equal); } return type; @@ -938,6 +947,40 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) /* ********************************************************************** */ +static void +efhd_bonobo_unknown(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +{ + static int partid; + char *classid; + + classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%p/%d", part, partid++); + em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); + camel_stream_printf(stream, "<object classid=\"%s\" type=\"%s\">\n", classid, info->mime_type); + g_free(classid); +} + +/* ********************************************************************** */ + +static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type) +{ + const EMFormatHandler *handle; + + handle = ((EMFormatClass *)efhd_parent)->find_handler(emf, mime_type); + if (handle == NULL + && efhd_use_component(mime_type) + && (handle = g_hash_table_lookup(efhd_bonobo_handlers, mime_type)) == NULL) { + EMFormatHandler *h = g_malloc0(sizeof(*h)); + + h->mime_type = g_strdup(mime_type); + h->handler = efhd_bonobo_unknown; + g_hash_table_insert(efhd_bonobo_handlers, h->mime_type, h); + + handle = h; + } + + return handle; +} + static void efhd_format_clone(EMFormat *emf, CamelMedium *part, EMFormat *src) { ((EMFormatClass *)efhd_parent)->format_clone(emf, part, src); diff --git a/mail/em-format.c b/mail/em-format.c index b3f9b9a344..6d16e48df0 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -57,6 +57,7 @@ static void emf_builtin_init(EMFormatClass *); static const char *emf_snoop_part(CamelMimePart *part); +static const EMFormatHandler *emf_find_handler(EMFormat *emf, const char *mime_type); static void emf_format_clone(EMFormat *emf, CamelMedium *msg, EMFormat *emfsource); static gboolean emf_busy(EMFormat *emf); @@ -111,6 +112,7 @@ emf_class_init(GObjectClass *klass) emf_builtin_init((EMFormatClass *)klass); klass->finalize = emf_finalise; + ((EMFormatClass *)klass)->find_handler = emf_find_handler; ((EMFormatClass *)klass)->format_clone = emf_format_clone; ((EMFormatClass *)klass)->busy = emf_busy; @@ -184,7 +186,6 @@ em_format_class_remove_handler (EMFormatClass *emfc, const char *mime_type) g_hash_table_remove (emfc->type_handlers, mime_type); } - /** * em_format_find_handler: * @emf: @@ -194,8 +195,8 @@ em_format_class_remove_handler (EMFormatClass *emfc, const char *mime_type) * * Return value: NULL if no handler is available. **/ -const EMFormatHandler * -em_format_find_handler(EMFormat *emf, const char *mime_type) +static const EMFormatHandler * +emf_find_handler(EMFormat *emf, const char *mime_type) { EMFormatClass *emfc = (EMFormatClass *)G_OBJECT_GET_CLASS(emf); diff --git a/mail/em-format.h b/mail/em-format.h index cc0f6bdd75..f4cbb3fbbc 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -126,6 +126,9 @@ struct _EMFormatClass { GHashTable *type_handlers; + /* lookup handler, default falls back to hashtable above */ + const EMFormatHandler *(*find_handler)(EMFormat *, const char *mime_type); + /* start formatting a message */ void (*format_clone)(EMFormat *, struct _CamelMedium *, EMFormat *); /* some internel error/inconsistency */ @@ -171,7 +174,7 @@ GType em_format_get_type(void); void em_format_class_add_handler(EMFormatClass *emfc, EMFormatHandler *info); void em_format_class_remove_handler (EMFormatClass *emfc, const char *mime_type); -const EMFormatHandler *em_format_find_handler(EMFormat *emf, const char *mime_type); +#define em_format_find_handler(emf, type) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->find_handler((emf), (type)) const EMFormatHandler *em_format_fallback_handler(EMFormat *emf, const char *mime_type); /* puri is short for pending uri ... really */ |