EMFormat: Add "session" as a constructor property.

Pass it in instead of digging it out of EShellSettings.
This commit is contained in:
Matthew Barnes
2012-03-31 12:08:36 -04:00
parent d15cd73588
commit 9ed9a99bad
15 changed files with 272 additions and 145 deletions

View File

@ -178,7 +178,8 @@ async_context_free (AsyncContext *context)
* Return Value: The part in displayable html format.
**/
static gchar *
emcu_part_to_html (CamelMimePart *part,
emcu_part_to_html (CamelSession *session,
CamelMimePart *part,
gssize *len,
EMFormat *source,
GCancellable *cancellable)
@ -192,7 +193,9 @@ emcu_part_to_html (CamelMimePart *part,
mem = (CamelStreamMem *) camel_stream_mem_new ();
camel_stream_mem_set_byte_array (mem, buf);
emfq = em_format_quote_new (NULL, (CamelStream *) mem, EM_FORMAT_QUOTE_KEEP_SIG);
emfq = em_format_quote_new (
session, NULL, (CamelStream *) mem,
EM_FORMAT_QUOTE_KEEP_SIG);
em_format_set_composer ((EMFormat *) emfq, TRUE);
if (source) {
/* Copy over things we can, other things are internal.
@ -2698,9 +2701,12 @@ handle_multipart_signed (EMsgComposer *composer,
CamelContentType *content_type;
CamelDataWrapper *content;
CamelMimePart *mime_part;
CamelSession *session;
GtkToggleAction *action = NULL;
const gchar *protocol;
session = e_msg_composer_get_session (composer);
content = CAMEL_DATA_WRAPPER (multipart);
content_type = camel_data_wrapper_get_mime_type_field (content);
protocol = camel_content_type_param (content_type, "protocol");
@ -2760,7 +2766,8 @@ handle_multipart_signed (EMsgComposer *composer,
gchar *html;
gssize length;
html = emcu_part_to_html (mime_part, &length, NULL, cancellable);
html = emcu_part_to_html (
session, mime_part, &length, NULL, cancellable);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@ -2847,7 +2854,8 @@ handle_multipart_encrypted (EMsgComposer *composer,
gchar *html;
gssize length;
html = emcu_part_to_html (mime_part, &length, NULL, cancellable);
html = emcu_part_to_html (
session, mime_part, &length, NULL, cancellable);
e_msg_composer_set_pending_body (composer, html, length);
} else {
e_msg_composer_attach (composer, mime_part);
@ -2864,8 +2872,11 @@ handle_multipart_alternative (EMsgComposer *composer,
{
/* Find the text/html part and set the composer body to it's contents */
CamelMimePart *text_part = NULL;
CamelSession *session;
gint i, nparts;
session = e_msg_composer_get_session (composer);
nparts = camel_multipart_get_number (multipart);
for (i = 0; i < nparts; i++) {
@ -2924,7 +2935,8 @@ handle_multipart_alternative (EMsgComposer *composer,
gchar *html;
gssize length;
html = emcu_part_to_html (text_part, &length, NULL, cancellable);
html = emcu_part_to_html (
session, text_part, &length, NULL, cancellable);
e_msg_composer_set_pending_body (composer, html, length);
}
}
@ -2935,8 +2947,11 @@ handle_multipart (EMsgComposer *composer,
GCancellable *cancellable,
gint depth)
{
CamelSession *session;
gint i, nparts;
session = e_msg_composer_get_session (composer);
nparts = camel_multipart_get_number (multipart);
for (i = 0; i < nparts; i++) {
@ -2989,7 +3004,7 @@ handle_multipart (EMsgComposer *composer,
/* Since the first part is not multipart/alternative,
* this must be the body. */
html = emcu_part_to_html (
mime_part, &length, NULL, cancellable);
session, mime_part, &length, NULL, cancellable);
e_msg_composer_set_pending_body (composer, html, length);
} else if (camel_mime_part_get_content_id (mime_part) ||
camel_mime_part_get_content_location (mime_part)) {
@ -3056,6 +3071,7 @@ e_msg_composer_new_with_message (EShell *shell,
CamelContentType *content_type;
struct _camel_header_raw *headers;
CamelDataWrapper *content;
CamelSession *session;
EAccount *account = NULL;
gchar *account_name;
EMsgComposer *composer;
@ -3081,6 +3097,7 @@ e_msg_composer_new_with_message (EShell *shell,
composer = e_msg_composer_new (shell);
priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
session = e_msg_composer_get_session (composer);
table = e_msg_composer_get_header_table (composer);
if (postto) {
@ -3356,7 +3373,7 @@ e_msg_composer_new_with_message (EShell *shell,
ACTION (SMIME_ENCRYPT)), TRUE);
html = emcu_part_to_html (
CAMEL_MIME_PART (message),
session, CAMEL_MIME_PART (message),
&length, NULL, cancellable);
e_msg_composer_set_pending_body (composer, html, length);
}

View File

@ -580,18 +580,22 @@ em_format_quote_get_type (void)
}
EMFormatQuote *
em_format_quote_new (const gchar *credits,
em_format_quote_new (CamelSession *session,
const gchar *credits,
CamelStream *stream,
EMFormatQuoteFlags flags)
{
EMFormatQuote *emfq;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
/* Steam must also be seekable so we can reset its position. */
g_return_val_if_fail (G_IS_SEEKABLE (stream), NULL);
emfq = g_object_new (EM_TYPE_FORMAT_QUOTE, NULL);
emfq = g_object_new (
EM_TYPE_FORMAT_QUOTE,
"session", session, NULL);
emfq->priv->credits = g_strdup (credits);
emfq->priv->flags = flags;

View File

@ -66,12 +66,13 @@ struct _EMFormatQuoteClass {
};
GType em_format_quote_get_type (void);
EMFormatQuote * em_format_quote_new (const gchar *credits,
EMFormatQuote * em_format_quote_new (CamelSession *session,
const gchar *credits,
CamelStream *stream,
EMFormatQuoteFlags flags);
void em_format_quote_write (EMFormatQuote *emfq,
CamelStream *stream,
GCancellable *cancellable);
void em_format_quote_write (EMFormatQuote *emfq,
CamelStream *stream,
GCancellable *cancellable);
G_END_DECLS

View File

@ -57,10 +57,11 @@ struct _EMFormatPrivate {
enum {
PROP_0,
PROP_BASE_URL,
PROP_CHARSET,
PROP_DEFAULT_CHARSET,
PROP_COMPOSER,
PROP_BASE_URL
PROP_DEFAULT_CHARSET,
PROP_SESSION
};
enum {
@ -1233,33 +1234,13 @@ static const struct {
};
static void
em_format_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
em_format_set_session (EMFormat *emf,
CamelSession *session)
{
EMFormat *emf = EM_FORMAT (object);
g_return_if_fail (CAMEL_IS_SESSION (session));
g_return_if_fail (emf->priv->session == NULL);
switch (property_id) {
case PROP_CHARSET:
g_value_set_string (
value, em_format_get_charset (emf));
return;
case PROP_DEFAULT_CHARSET:
g_value_set_string (
value, em_format_get_default_charset (emf));
return;
case PROP_COMPOSER:
g_value_set_boolean (
value, em_format_get_composer (emf));
return;
case PROP_BASE_URL:
g_value_set_object (
value, em_format_get_base_url (emf));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
emf->priv->session = g_object_ref (session);
}
static void
@ -1268,24 +1249,35 @@ em_format_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
EMFormat *emf = EM_FORMAT (object);
switch (property_id) {
case PROP_CHARSET:
em_format_set_charset (emf,
g_value_get_string (value));
return;
case PROP_DEFAULT_CHARSET:
em_format_set_default_charset (emf,
g_value_get_string (value));
return;
case PROP_COMPOSER:
em_format_set_composer (emf,
g_value_get_boolean (value));
return;
case PROP_BASE_URL:
em_format_set_base_url (emf,
g_value_get_object (value));
em_format_set_base_url (
EM_FORMAT (object),
g_value_get_object (value));
return;
case PROP_CHARSET:
em_format_set_charset (
EM_FORMAT (object),
g_value_get_string (value));
return;
case PROP_COMPOSER:
em_format_set_composer (
EM_FORMAT (object),
g_value_get_boolean (value));
return;
case PROP_DEFAULT_CHARSET:
em_format_set_default_charset (
EM_FORMAT (object),
g_value_get_string (value));
return;
case PROP_SESSION:
em_format_set_session (
EM_FORMAT (object),
g_value_get_object (value));
return;
}
@ -1293,6 +1285,47 @@ em_format_set_property (GObject *object,
}
static void
em_format_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_BASE_URL:
g_value_set_object (
value, em_format_get_base_url (
EM_FORMAT (object)));
return;
case PROP_CHARSET:
g_value_set_string (
value, em_format_get_charset (
EM_FORMAT (object)));
return;
case PROP_COMPOSER:
g_value_set_boolean (
value, em_format_get_composer (
EM_FORMAT (object)));
return;
case PROP_DEFAULT_CHARSET:
g_value_set_string (
value, em_format_get_default_charset (
EM_FORMAT (object)));
return;
case PROP_SESSION:
g_value_set_object (
value, em_format_get_session (
EM_FORMAT (object)));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
em_format_finalize (GObject *object)
{
@ -1352,69 +1385,88 @@ em_format_finalize (GObject *object)
}
static void
em_format_base_init (EMFormatClass *klass)
em_format_base_init (EMFormatClass *class)
{
gint i;
klass->type_handlers = g_hash_table_new (g_str_hash, g_str_equal);
class->type_handlers = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (type_handlers); i++) {
g_hash_table_insert (klass->type_handlers,
g_hash_table_insert (class->type_handlers,
type_handlers[i].mime_type,
&type_handlers[i]);
}
}
static void
em_format_class_init (EMFormatClass *klass)
em_format_class_init (EMFormatClass *class)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (klass, sizeof (EMFormatPrivate));
g_type_class_add_private (class, sizeof (EMFormatPrivate));
klass->is_inline = emf_is_inline;
class->is_inline = emf_is_inline;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = em_format_finalize;
object_class->get_property = em_format_get_property;
object_class = G_OBJECT_CLASS (class);
object_class->set_property = em_format_set_property;
object_class->get_property = em_format_get_property;
object_class->finalize = em_format_finalize;
g_object_class_install_property (object_class,
PROP_CHARSET,
g_param_spec_string ("charset",
NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_BASE_URL,
g_param_spec_pointer (
"base-url",
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_DEFAULT_CHARSET,
g_param_spec_string ("default-charset",
NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_CHARSET,
g_param_spec_string (
"charset",
NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_COMPOSER,
g_param_spec_boolean ("composer",
NULL,
NULL,
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_COMPOSER,
g_param_spec_boolean (
"composer",
NULL,
NULL,
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_BASE_URL,
g_param_spec_pointer ("base-url",
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_DEFAULT_CHARSET,
g_param_spec_string (
"default-charset",
NULL,
NULL,
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_SESSION,
g_param_spec_object (
"session",
"Session",
"A CamelSession",
CAMEL_TYPE_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
signals[REDRAW_REQUESTED] = g_signal_new (
"redraw-requested",
G_TYPE_FROM_CLASS (klass),
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMFormatClass, redraw_requested),
NULL, NULL,
@ -1434,11 +1486,7 @@ mail_part_table_item_free (gpointer data)
static void
em_format_init (EMFormat *emf)
{
EShell *shell;
EShellSettings *shell_settings;
emf->priv = G_TYPE_INSTANCE_GET_PRIVATE (emf,
EM_TYPE_FORMAT, EMFormatPrivate);
emf->priv = EM_FORMAT_GET_PRIVATE (emf);
emf->message = NULL;
emf->folder = NULL;
@ -1447,16 +1495,8 @@ em_format_init (EMFormat *emf)
NULL, (GDestroyNotify) mail_part_table_item_free);
/* No need to free the key, because it's owned and free'd by the PURI */
shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
emf->priv->last_error = 0;
emf->priv->session = e_shell_settings_get_pointer (shell_settings, "mail-session");
g_return_if_fail (emf->priv->session);
g_object_ref (emf->priv->session);
em_format_default_headers (emf);
}
@ -1560,6 +1600,14 @@ em_format_get_composer (EMFormat *emf)
return emf->priv->composer;
}
CamelSession *
em_format_get_session (EMFormat *emf)
{
g_return_val_if_fail (EM_IS_FORMAT (emf), NULL);
return emf->priv->session;
}
void
em_format_set_base_url (EMFormat *emf,
CamelURL *url)
@ -2051,17 +2099,17 @@ em_format_is_inline (EMFormat *emf,
CamelMimePart *part,
const EMFormatHandler *handler)
{
EMFormatClass *klass;
EMFormatClass *class;
g_return_val_if_fail (EM_IS_FORMAT (emf), FALSE);
g_return_val_if_fail (part_id && *part_id, FALSE);
g_return_val_if_fail (CAMEL_IS_MIME_PART (part), FALSE);
g_return_val_if_fail (handler, FALSE);
klass = EM_FORMAT_GET_CLASS (emf);
g_return_val_if_fail (klass->is_inline != NULL, FALSE);
class = EM_FORMAT_GET_CLASS (emf);
g_return_val_if_fail (class->is_inline != NULL, FALSE);
return klass->is_inline (emf, part_id, part, handler);
return class->is_inline (emf, part_id, part, handler);
}

View File

@ -222,6 +222,8 @@ void em_format_set_composer (EMFormat *emf,
gboolean composer);
gboolean em_format_get_composer (EMFormat *emf);
CamelSession * em_format_get_session (EMFormat *emf);
void em_format_set_base_url (EMFormat *emf,
CamelURL *url);
void em_format_set_base_url_string (EMFormat *emf,

View File

@ -3099,6 +3099,8 @@ mail_reader_set_display_formatter_for_message (EMailReader *reader,
}
if ((formatter = g_hash_table_lookup (formatters, mail_uri)) == NULL) {
EMailBackend *mail_backend;
EMailSession *mail_session;
struct _formatter_weak_ref_closure *formatter_data =
g_new0 (struct _formatter_weak_ref_closure, 1);
@ -3107,7 +3109,12 @@ mail_reader_set_display_formatter_for_message (EMailReader *reader,
formatter_data->formatters = g_hash_table_ref (formatters);
formatter_data->mail_uri = g_strdup (mail_uri);
formatter = EM_FORMAT (em_format_html_display_new ());
mail_backend = e_mail_reader_get_backend (reader);
mail_session = e_mail_backend_get_session (mail_backend);
formatter = EM_FORMAT (
em_format_html_display_new (
CAMEL_SESSION (mail_session)));
/* When no EMailDisplay holds reference to the formatter, then
* the formatter can be destroyed. */

View File

@ -950,9 +950,12 @@ em_utils_composer_print_cb (EMsgComposer *composer,
{
EMailPrinter *emp;
EMFormatHTMLDisplay *efhd;
const gchar *message_id;
efhd = em_format_html_display_new ();
((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
efhd = em_format_html_display_new (CAMEL_SESSION (session));
message_id = camel_mime_message_get_message_id (message);
((EMFormat *) efhd)->message_uid = g_strdup (message_id);
/* Parse the message */
em_format_parse ((EMFormat *) efhd, message, NULL, NULL);
@ -1651,6 +1654,7 @@ forward_attached_cb (CamelFolder *folder,
static EMsgComposer *
forward_non_attached (EShell *shell,
CamelSession *session,
CamelFolder *folder,
const gchar *uid,
CamelMimeMessage *message,
@ -1667,7 +1671,7 @@ forward_non_attached (EShell *shell,
forward = quoting_text (QUOTING_FORWARD);
text = em_utils_message_to_html (
message, forward, flags, NULL, NULL, &validity_found);
session, message, forward, flags, NULL, NULL, &validity_found);
if (text != NULL) {
CamelDataWrapper *content;
@ -1713,6 +1717,7 @@ forward_non_attached (EShell *shell,
/**
* em_utils_forward_message:
* @shell: an #EShell
* @session: a #CamelSession
* @message: a #CamelMimeMessage to forward
* @style: the forward style to use
* @folder: a #CamelFolder, or %NULL
@ -1723,6 +1728,7 @@ forward_non_attached (EShell *shell,
**/
EMsgComposer *
em_utils_forward_message (EShell *shell,
CamelSession *session,
CamelMimeMessage *message,
EMailForwardStyle style,
CamelFolder *folder,
@ -1733,6 +1739,7 @@ em_utils_forward_message (EShell *shell,
EMsgComposer *composer = NULL;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
switch (style) {
@ -1751,7 +1758,7 @@ em_utils_forward_message (EShell *shell,
case E_MAIL_FORWARD_STYLE_INLINE:
case E_MAIL_FORWARD_STYLE_QUOTED:
composer = forward_non_attached (
shell, folder, uid, message, style);
shell, session, folder, uid, message, style);
break;
}
@ -1765,6 +1772,7 @@ forward_got_messages_cb (CamelFolder *folder,
{
EShell *shell;
EMailBackend *backend;
EMailSession *session;
EAlertSink *alert_sink;
GHashTable *hash_table;
GHashTableIter iter;
@ -1798,6 +1806,7 @@ forward_got_messages_cb (CamelFolder *folder,
g_return_if_fail (hash_table != NULL);
backend = e_mail_reader_get_backend (context->reader);
session = e_mail_backend_get_session (backend);
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
/* Create a new composer window for each message. */
@ -1806,7 +1815,8 @@ forward_got_messages_cb (CamelFolder *folder,
while (g_hash_table_iter_next (&iter, &key, &value))
em_utils_forward_message (
shell, value, context->style, folder, key);
shell, CAMEL_SESSION (session),
value, context->style, folder, key);
g_hash_table_unref (hash_table);
@ -2674,10 +2684,13 @@ composer_set_body (EMsgComposer *composer,
{
gchar *text, *credits, *original;
CamelMimePart *part;
CamelSession *session;
GSettings *settings;
gboolean start_bottom, has_body_text = FALSE;
guint32 validity_found = 0;
session = e_msg_composer_get_session (composer);
settings = g_settings_new ("org.gnome.evolution.mail");
start_bottom = g_settings_get_boolean (settings, "composer-reply-start-bottom");
@ -2695,8 +2708,8 @@ composer_set_body (EMsgComposer *composer,
case E_MAIL_REPLY_STYLE_OUTLOOK:
original = quoting_text (QUOTING_ORIGINAL);
text = em_utils_message_to_html (
message, original, EM_FORMAT_QUOTE_HEADERS, source,
start_bottom ? "<BR>" : NULL, &validity_found);
session, message, original, EM_FORMAT_QUOTE_HEADERS,
source, start_bottom ? "<BR>" : NULL, &validity_found);
e_msg_composer_set_body_text (composer, text, TRUE);
has_body_text = text && *text;
g_free (text);
@ -2709,8 +2722,8 @@ composer_set_body (EMsgComposer *composer,
/* do what any sane user would want when replying... */
credits = attribution_format (message);
text = em_utils_message_to_html (
message, credits, EM_FORMAT_QUOTE_CITE, source,
start_bottom ? "<BR>" : NULL, &validity_found);
session, message, credits, EM_FORMAT_QUOTE_CITE,
source, start_bottom ? "<BR>" : NULL, &validity_found);
g_free (credits);
e_msg_composer_set_body_text (composer, text, TRUE);
has_body_text = text && *text;
@ -2747,18 +2760,21 @@ composer_set_body (EMsgComposer *composer,
}
gchar *
em_utils_construct_composer_text (CamelMimeMessage *message,
em_utils_construct_composer_text (CamelSession *session,
CamelMimeMessage *message,
EMFormat *source)
{
gchar *text, *credits;
gboolean start_bottom = 0;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
credits = attribution_format (message);
text = em_utils_message_to_html (
message, credits, EM_FORMAT_QUOTE_CITE, source,
start_bottom ? "<BR>" : NULL, NULL);
session, message, credits, EM_FORMAT_QUOTE_CITE,
source, start_bottom ? "<BR>" : NULL, NULL);
g_free (credits);
return text;
}

View File

@ -47,6 +47,7 @@ void em_utils_edit_messages (EMailReader *reader,
GPtrArray *uids,
gboolean replace);
EMsgComposer * em_utils_forward_message (EShell *shell,
CamelSession *session,
CamelMimeMessage *msg,
EMailForwardStyle style,
CamelFolder *folder,
@ -59,7 +60,8 @@ void em_utils_forward_messages (EMailReader *reader,
void em_utils_redirect_message (EShell *shell,
CamelMimeMessage *message);
gchar * em_utils_construct_composer_text
(CamelMimeMessage *message,
(CamelSession *session,
CamelMimeMessage *message,
EMFormat *source_formatter);
gboolean em_utils_is_munged_list_message (CamelMimeMessage *message);
void em_utils_get_reply_sender (CamelMimeMessage *message,

View File

@ -916,9 +916,13 @@ em_format_html_display_get_type (void)
}
EMFormatHTMLDisplay *
em_format_html_display_new (void)
em_format_html_display_new (CamelSession *session)
{
return g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL);
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
return g_object_new (
EM_TYPE_FORMAT_HTML_DISPLAY,
"session", session, NULL);
}
/* ********************************************************************** */

View File

@ -111,7 +111,7 @@ struct _EMFormatHTMLDisplayClass {
GType em_format_html_display_get_type (void);
EMFormatHTMLDisplay *
em_format_html_display_new (void);
em_format_html_display_new (CamelSession *session);
G_END_DECLS
#endif /* EM_FORMAT_HTML_DISPLAY_H */

View File

@ -618,8 +618,15 @@ EMFormatHTMLPrint *
em_format_html_print_new (EMFormatHTML *source)
{
EMFormatHTMLPrint *efhp;
CamelSession *session;
efhp = g_object_new (EM_TYPE_FORMAT_HTML_PRINT,
g_return_val_if_fail (EM_IS_FORMAT_HTML (source), NULL);
session = em_format_get_session (EM_FORMAT (source));
efhp = g_object_new (
EM_TYPE_FORMAT_HTML_PRINT,
"session", session,
"original-formatter", source,
NULL);

View File

@ -646,12 +646,17 @@ em_utils_print_messages_to_file (CamelFolder *folder,
{
EMFormatHTMLDisplay *efhd;
CamelMimeMessage *message;
CamelStore *parent_store;
CamelSession *session;
message = camel_folder_get_message_sync (folder, uid, NULL, NULL);
if (message == NULL)
return FALSE;
efhd = em_format_html_display_new ();
parent_store = camel_folder_get_parent_store (folder);
session = camel_service_get_session (CAMEL_SERVICE (parent_store));
efhd = em_format_html_display_new (session);
((EMFormat *) efhd)->message_uid = g_strdup (uid);
em_format_parse_async ((EMFormat *) efhd, message, folder, NULL,
@ -1162,6 +1167,7 @@ em_utils_get_proxy (void)
/**
* em_utils_message_to_html:
* @session: a #CamelSession
* @message:
* @credits:
* @flags: EMFormatQuote flags
@ -1177,7 +1183,8 @@ em_utils_get_proxy (void)
* Return value: The html version as a NULL terminated string.
**/
gchar *
em_utils_message_to_html (CamelMimeMessage *message,
em_utils_message_to_html (CamelSession *session,
CamelMimeMessage *message,
const gchar *credits,
guint32 flags,
EMFormat *source,
@ -1188,11 +1195,13 @@ em_utils_message_to_html (CamelMimeMessage *message,
CamelStream *mem;
GByteArray *buf;
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
buf = g_byte_array_new ();
mem = camel_stream_mem_new ();
camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (mem), buf);
emfq = em_format_quote_new (credits, mem, flags);
emfq = em_format_quote_new (session, credits, mem, flags);
em_format_set_composer ((EMFormat *) emfq, TRUE);
if (!source) {

View File

@ -68,7 +68,7 @@ void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder
EProxy * em_utils_get_proxy (void);
/* FIXME: should this have an override charset? */
gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found);
gchar *em_utils_message_to_html (CamelSession *session, CamelMimeMessage *msg, const gchar *credits, guint32 flags, struct _EMFormat *source, const gchar *append, guint32 *validity_found);
void em_utils_empty_trash (GtkWidget *parent,
EMailSession *session);

View File

@ -89,7 +89,8 @@ mail_attachment_handler_forward (GtkAction *action,
style = e_shell_settings_get_int (shell_settings, property_name);
em_utils_forward_message (
priv->shell, CAMEL_MIME_MESSAGE (wrapper), style, NULL, NULL);
priv->shell, CAMEL_SESSION (priv->session),
CAMEL_MIME_MESSAGE (wrapper), style, NULL, NULL);
g_list_foreach (selected, (GFunc) g_object_unref, NULL);
g_list_free (selected);

View File

@ -844,7 +844,7 @@ message_parsed_cb (GObject *source_object,
GObject *preview = user_data;
EMailDisplay *display;
display = g_object_get_data (preview, "mbox-imp-display");
display = g_object_get_data (preview, "mbox-imp-display");
e_mail_display_set_formatter (display, formatter);
e_mail_display_load (display, EM_FORMAT (formatter)->uri_base);
}
@ -860,10 +860,10 @@ mbox_create_preview_cb (GObject *preview,
g_return_if_fail (preview_widget != NULL);
display = g_object_new (E_TYPE_MAIL_DISPLAY, NULL);
g_object_set_data_full (preview, "mbox-imp-display",
g_object_set_data_full (preview, "mbox-imp-display",
g_object_ref (display), g_object_unref);
*preview_widget = GTK_WIDGET (display);
*preview_widget = GTK_WIDGET (display);
}
static void
@ -873,7 +873,8 @@ mbox_fill_preview_cb (GObject *preview,
EMailDisplay *display;
EMFormat *formatter;
GHashTable *formatters;
SoupSession *session;
SoupSession *soup_session;
EMailSession *mail_session;
gchar *mail_uri;
g_return_if_fail (preview != NULL);
@ -882,23 +883,31 @@ mbox_fill_preview_cb (GObject *preview,
display = g_object_get_data (preview, "mbox-imp-display");
g_return_if_fail (display != NULL);
session = webkit_get_default_session ();
formatters = g_object_get_data (G_OBJECT (session), "formatters");
soup_session = webkit_get_default_session ();
formatters = g_object_get_data (G_OBJECT (soup_session), "formatters");
if (!formatters) {
formatters = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free, NULL);
g_object_set_data (G_OBJECT (session), "formatters", formatters);
g_object_set_data (
G_OBJECT (soup_session), "formatters", formatters);
}
mail_uri = em_format_build_mail_uri (NULL, msg->message_id, NULL, NULL);
formatter = EM_FORMAT (em_format_html_display_new ());
mail_session = e_mail_session_new ();
formatter = EM_FORMAT (
em_format_html_display_new (
CAMEL_SESSION (mail_session)));
formatter->message_uid = g_strdup (msg->message_id);
formatter->uri_base = g_strdup (mail_uri);
/* Don't free the mail_uri!! */
g_hash_table_insert (formatters, mail_uri, formatter);
em_format_parse_async (formatter, msg, NULL, NULL,
message_parsed_cb, preview);
em_format_parse_async (
formatter, msg, NULL, NULL,
message_parsed_cb, preview);
g_object_unref (mail_session);
}