[evolution/webkit: 33/113] Add attachments to store during parsing, not during writing
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 33/113] Add attachments to store during parsing, not during writing
- Date: Tue, 10 Jan 2012 09:51:22 +0000 (UTC)
commit ba5dc4367f71b53661e4b575a7c4bf5e979e34c8
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Sep 22 15:25:23 2011 +0200
Add attachments to store during parsing, not during writing
em-format/em-format.c | 17 ------
mail/e-mail-display.c | 2 +
mail/em-format-html-display.c | 110 ++++++++++++++++++++---------------------
mail/em-format-html.c | 2 +-
4 files changed, 57 insertions(+), 74 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index d5336e1..d3eb1b1 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -77,7 +77,6 @@ static void emf_parse_message (EMFormat *emf, CamelMimePart *part, GString *pa
static void emf_parse_headers (EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
static void emf_parse_post_headers (EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
static void emf_parse_source (EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
-static void emf_parse_attachment (EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
/* WRITERS */
static void emf_write_text (EMFormat *emf, EMFormatPURI *puri, CamelStream *stream, GCancellable *cancellable) {};
@@ -1062,21 +1061,6 @@ emf_parse_source (EMFormat *emf,
em_format_add_puri (emf, puri);
}
-static void
-emf_parse_attachment (EMFormat *emf,
- CamelMimePart *part,
- GString *part_id,
- EMFormatParserInfo *info,
- GCancellable *cancellable)
-{
- EMFormatPURI *puri;
-
- puri = em_format_puri_new (emf, sizeof (EMFormatPURI), part, part_id->str);
- puri->is_attachment = TRUE;
-
- em_format_add_puri (emf, puri);
-}
-
/**************************************************************************/
void
@@ -1209,7 +1193,6 @@ static EMFormatHandler type_handlers[] = {
{ (gchar *) "x-evolution/message/headers", emf_parse_headers, },
{ (gchar *) "x-evolution/message/post-headers", emf_parse_post_headers, },
{ (gchar *) "x-evolution/message/source", emf_parse_source, },
- { (gchar *) "x-evolution/message/attachment", emf_parse_attachment, },
};
/* note: also copied in em-mailer-prefs.c */
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index d6cd8dd..6968d0c 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -674,6 +674,8 @@ e_mail_display_load (EMailDisplay *display,
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
+
+ g_object_ref (widget);
} else
gtk_widget_show (widget);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 5f43f56..4989057 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -377,12 +377,18 @@ efhd_parse_attachment (EMFormat *emf,
GCancellable *cancellable)
{
gchar *text, *html;
+ EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf;
EMFormatAttachmentPURI *puri;
+ EAttachmentStore *store;
+ EShell *shell;
+ GtkWindow *window;
+ GtkWidget *parent;
const EMFormatHandler *handler;
CamelContentType *ct;
gchar *mime_type;
gint len;
const gchar *cid;
+ guint32 size;
if (g_cancellable_is_cancelled (cancellable))
return;
@@ -426,6 +432,51 @@ efhd_parse_attachment (EMFormat *emf,
em_format_add_puri (emf, (EMFormatPURI *) puri);
e_attachment_set_mime_part (puri->attachment, part);
+ e_attachment_set_shown (puri->attachment, puri->shown);
+ e_attachment_set_signed (puri->attachment, puri->sign);
+ e_attachment_set_encrypted (puri->attachment, puri->encrypt);
+ e_attachment_set_can_show (puri->attachment, puri->handle != NULL && puri->handle->write_func);
+
+ /* FIXME: Try to find a better way? */
+ shell = e_shell_get_default ();
+ window = e_shell_get_active_window (shell);
+ if (E_IS_SHELL_WINDOW (window))
+ parent = GTK_WIDGET (window);
+ else
+ parent = NULL;
+
+ store = e_attachment_view_get_store (efhd->priv->attachment_view);
+ e_attachment_store_add_attachment (store, puri->attachment);
+
+ if (emf->folder && emf->folder->summary && emf->message_uid) {
+ CamelMessageInfo *mi;
+
+ mi = camel_folder_summary_get (emf->folder->summary, emf->message_uid);
+ if (mi) {
+ const CamelMessageContentInfo *ci;
+
+ ci = camel_folder_summary_guess_content_info (mi,
+ camel_mime_part_get_content_type (puri->puri.part));
+ if (ci) {
+ size = ci->size;
+ /* what if its not encoded in base64 ? is it a case to consider? */
+ if (ci->encoding && !g_ascii_strcasecmp (ci->encoding, "base64"))
+ size = size / 1.37;
+ }
+ camel_message_info_free (mi);
+ }
+ }
+
+ e_attachment_load_async (
+ puri->attachment, (GAsyncReadyCallback)
+ e_attachment_load_handle_error, parent);
+ if (size != 0) {
+ GFileInfo *fileinfo;
+
+ fileinfo = e_attachment_get_file_info (puri->attachment);
+ g_file_info_set_size (fileinfo, size);
+ e_attachment_set_file_info (puri->attachment, fileinfo);
+ }
if (info->validity) {
puri->sign = info->validity->sign.status;
@@ -902,19 +953,13 @@ efhd_message_prefix (EMFormat *emf,
/* attachment button callback */
static GtkWidget*
efhd_attachment_button (EMFormat *emf,
- EMFormatPURI *puri,
- GCancellable *cancellable)
+ EMFormatPURI *puri,
+ GCancellable *cancellable)
{
- EShell *shell;
- GtkWindow *window;
EMFormatAttachmentPURI *info = (EMFormatAttachmentPURI *) puri;
EMFormatHTML *efh = (EMFormatHTML *) emf;
EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh;
- EAttachmentStore *store;
- EAttachment *attachment;
GtkWidget *widget;
- gpointer parent;
- guint32 size = 0;
/* FIXME: handle default shown case */
d(printf("adding attachment button/content\n"));
@@ -922,61 +967,14 @@ efhd_attachment_button (EMFormat *emf,
if (g_cancellable_is_cancelled (cancellable))
return NULL;
- if (emf->folder && emf->folder->summary && emf->message_uid) {
- CamelMessageInfo *mi;
-
- mi = camel_folder_summary_get (emf->folder->summary, emf->message_uid);
- if (mi) {
- const CamelMessageContentInfo *ci;
-
- ci = camel_folder_summary_guess_content_info (mi,
- camel_mime_part_get_content_type (info->puri.part));
- if (ci) {
- size = ci->size;
- /* what if its not encoded in base64 ? is it a case to consider? */
- if (ci->encoding && !g_ascii_strcasecmp (ci->encoding, "base64"))
- size = size / 1.37;
- }
- camel_message_info_free (mi);
- }
- }
-
if (!info || info->forward) {
g_warning ("unable to expand the attachment\n");
return NULL;
}
- attachment = info->attachment;
- e_attachment_set_shown (attachment, info->shown);
- e_attachment_set_signed (attachment, info->sign);
- e_attachment_set_encrypted (attachment, info->encrypt);
- e_attachment_set_can_show (attachment, info->handle != NULL && info->handle->write_func);
-
- /* FIXME: Try to find a better way? */
- shell = e_shell_get_default ();
- window = e_shell_get_active_window (shell);
- if (E_IS_SHELL_WINDOW (window))
- parent = GTK_WIDGET (window);
- else
- parent = NULL;
-
- store = e_attachment_view_get_store (efhd->priv->attachment_view);
- e_attachment_store_add_attachment (store, info->attachment);
-
- e_attachment_load_async (
- info->attachment, (GAsyncReadyCallback)
- e_attachment_load_handle_error, parent);
- if (size != 0) {
- GFileInfo *fileinfo;
-
- fileinfo = e_attachment_get_file_info (info->attachment);
- g_file_info_set_size (fileinfo, size);
- e_attachment_set_file_info (info->attachment, fileinfo);
- }
-
widget = e_attachment_button_new (efhd->priv->attachment_view);
e_attachment_button_set_attachment (
- E_ATTACHMENT_BUTTON (widget), attachment);
+ E_ATTACHMENT_BUTTON (widget), info->attachment);
gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_show (widget);
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index d20aa1b..9e6891c 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -166,7 +166,7 @@ efh_parse_image (EMFormat *emf,
tmp = camel_mime_part_get_content_id (part);
if (!tmp) {
- em_format_parse_part_as (emf, part, part_id, info, "x-evolution/message-attachment", cancellable);
+ em_format_parse_part_as (emf, part, part_id, info, "x-evolution/message/attachment", cancellable);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]