aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-format-html.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-07-10 09:31:04 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-07-10 09:31:04 +0800
commit27f894733e551067737a21bc21259ccbda60c777 (patch)
treea32a38714a27a064efcd1306bc154a11365af6f0 /mail/em-format-html.c
parent991e6790184c21f39e27047ef165c5da3703b4c8 (diff)
downloadgsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar.gz
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar.bz2
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar.lz
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar.xz
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.tar.zst
gsoc2013-evolution-27f894733e551067737a21bc21259ccbda60c777.zip
only call expunge if the folder is set. (emfb_enable_map[]): only enable
2004-07-09 Not Zed <NotZed@Ximian.com> * em-folder-browser.c (emfb_folder_expunge): only call expunge if the folder is set. (emfb_enable_map[]): only enable expunge menu item if we have a valid folder set. ** See bug #60900. * em-format-html.c: convert the text_inline_parts hash to be keyed off the partid. (efh_free_inline_parts): -> efh_free_cache and fix to do it. * em-format.c (emf_free_cache): make the inline table cache other info too based on partid, this frees the structure. (emf_clone_inlines): copy all of the cache data. (em_format_is_inline): use the new data structure to determine state. (em_format_set_inline): same for setting. (emf_multipart_signed): cache/lookup the cached part. (emf_insert_cache): helper to add a cache entry. (emf_multipart_encrypted): cache decrypted part. (emf_application_xpkcs7mime): same. 2004-07-08 Not Zed <NotZed@Ximian.com> ** See bug #60900 (related only). * em-format-html-display.c (efhd_attachment_show): let set_inline do the redraw itself if required. kill some dead code. * em-format.c (em_format_set_inline): trigger a redraw here like the other em_format_set methods, if the state changed. * em-format.c (emf_format_clone): free inline table keys & setup string hash table. * em-format-quote.c (emfq_format_attachment): * em-format-html-display.c (efhd_format_attachment): * em-format-html.c (efh_format_attachment): is_inline api changes. * em-format-html-display.c (efhd_attachment_show): set_inline api changes. * em-format.c (em_format_is_inline): make this use the partid rather than the part address as a key, which may change. (emf_init): make the inline talbe a string hashtable. (emf_finalise): free inline keys. (emf_clone_inlines): copy the key string. svn path=/trunk/; revision=26614
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r--mail/em-format-html.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 0cb3e15cb2..d84238fda0 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -75,13 +75,19 @@
#define EFH_TABLE_OPEN "<table>"
+struct _EMFormatHTMLCache {
+ CamelMultipart *textmp;
+
+ char partid[1];
+};
+
struct _EMFormatHTMLPrivate {
struct _CamelMimeMessage *last_part; /* not reffed, DO NOT dereference */
volatile int format_id; /* format thread id */
guint format_timeout_id;
struct _format_msg *format_timeout_msg;
- /* Table that re-maps text parts into a mutlipart/mixed */
+ /* Table that re-maps text parts into a mutlipart/mixed, EMFormatHTMLCache * */
GHashTable *text_inline_parts;
EDList pending_jobs;
@@ -120,7 +126,7 @@ efh_init(GObject *o)
e_dlist_init(&efh->priv->pending_jobs);
efh->priv->lock = g_mutex_new();
efh->priv->format_id = -1;
- efh->priv->text_inline_parts = g_hash_table_new(NULL, NULL);
+ efh->priv->text_inline_parts = g_hash_table_new(g_str_hash, g_str_equal);
efh->html = (GtkHTML *)gtk_html_new();
gtk_html_set_blocking(efh->html, FALSE);
@@ -163,10 +169,27 @@ efh_gtkhtml_destroy(GtkHTML *html, EMFormatHTML *efh)
}
}
+static struct _EMFormatHTMLCache *
+efh_insert_cache(EMFormatHTML *efh, const char *partid)
+{
+ struct _EMFormatHTMLCache *efhc;
+
+ efhc = g_malloc0(sizeof(*efh) + strlen(partid));
+ strcpy(efhc->partid, partid);
+ g_hash_table_insert(efh->priv->text_inline_parts, efhc->partid, efhc);
+
+ return efhc;
+}
+
+
static void
-efh_free_inline_parts(void *key, void *data, void *user)
+efh_free_cache(void *key, void *val, void *dat)
{
- camel_object_unref(data);
+ struct _EMFormatHTMLCache *efhc = val;
+
+ if (efhc->textmp)
+ camel_object_unref(efhc->textmp);
+ g_free(efhc);
}
static void
@@ -180,7 +203,7 @@ efh_finalise(GObject *o)
efh_gtkhtml_destroy(efh->html, efh);
- g_hash_table_foreach(efh->priv->text_inline_parts, efh_free_inline_parts, NULL);
+ g_hash_table_foreach(efh->priv->text_inline_parts, efh_free_cache, NULL);
g_hash_table_destroy(efh->priv->text_inline_parts);
g_free(efh->priv);
@@ -635,7 +658,8 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
const char *format;
guint32 flags;
int i, count, len;
-
+ struct _EMFormatHTMLCache *efhc;
+
camel_stream_printf (stream,
"<table bgcolor=\"#%06x\" cellspacing=0 cellpadding=1 width=100%%><tr><td>\n"
"<table bgcolor=\"#%06x\" cellspacing=0 cellpadding=0 width=100%%><tr><td>\n"
@@ -663,8 +687,8 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
filters a bit. Perhaps the superclass should just deal with
html anyway and be done with it ... */
- mp = g_hash_table_lookup(efh->priv->text_inline_parts, part);
- if (mp == NULL) {
+ efhc = g_hash_table_lookup(efh->priv->text_inline_parts, ((EMFormat *)efh)->part_id->str);
+ if (efhc == NULL || (mp = efhc->textmp) == NULL) {
EMInlineFilter *inline_filter;
CamelStream *null;
CamelContentType *ct;
@@ -685,8 +709,12 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
camel_data_wrapper_write_to_stream(dw, (CamelStream *)filtered_stream);
camel_stream_close((CamelStream *)filtered_stream);
camel_object_unref(filtered_stream);
+
mp = em_inline_filter_get_multipart(inline_filter);
- g_hash_table_insert(efh->priv->text_inline_parts, part, mp);
+ if (efhc == NULL)
+ efhc = efh_insert_cache(efh, ((EMFormat *)efh)->part_id->str);
+ efhc->textmp = mp;
+
camel_object_unref(inline_filter);
camel_content_type_unref(ct);
}
@@ -1292,9 +1320,9 @@ efh_format_timeout(struct _format_msg *m)
| GTK_HTML_BEGIN_BLOCK_UPDATES | GTK_HTML_BEGIN_BLOCK_IMAGES);
} else {
/* clear cache of inline-scanned text parts */
- g_hash_table_foreach(p->text_inline_parts, efh_free_inline_parts, NULL);
+ g_hash_table_foreach(p->text_inline_parts, efh_free_cache, NULL);
g_hash_table_destroy(p->text_inline_parts);
- p->text_inline_parts = g_hash_table_new(NULL, NULL);
+ p->text_inline_parts = g_hash_table_new(g_str_hash, g_str_equal);
p->last_part = m->message;
}
@@ -1747,7 +1775,7 @@ efh_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c
camel_stream_write_string(stream, "</font></td></tr><tr></table>");
- if (handle && em_format_is_inline(emf, part, handle))
+ if (handle && em_format_is_inline(emf, emf->part_id->str, part, handle))
handle->handler(emf, stream, part, handle);
}