Beispiel #1
0
static void /* ie., parts that require opening the message file */
add_file_parts (JsonBuilder *bob, MuMsg *msg, MuMsgOptions opts)
{
	const char	*str;
	GError		*err;

	err = NULL;

	if (!mu_msg_load_msg_file (msg, &err)) {
		g_warning ("failed to load message file: %s",
			   err ? err->message : "some error occured");
		g_clear_error (&err);
		return;
	}

	add_parts (bob, msg, opts);
	add_contacts (bob, msg);

	/* add the user-agent / x-mailer */
	str = mu_msg_get_header (msg, "User-Agent");
	if (!str)
		str = mu_msg_get_header (msg, "X-Mailer");
	add_string_member (bob, "user-agent", str);
	add_body_txt_params (bob, msg, opts);
	add_string_member (bob, "body-txt", mu_msg_get_body_text(msg, opts));
	add_string_member (bob, "body-html", mu_msg_get_body_html(msg, opts));
}
Beispiel #2
0
void
mu_msg_body_view_set_message (MuMsgBodyView *self, MuMsg *msg)
{
	const char* data;
	
	g_return_if_fail (self);

	set_message (self, msg);

	data = msg ? mu_msg_get_body_html (msg) : "";
	if (data) 
		set_html (self, data);
	else
		set_text (self, mu_msg_get_body_text (msg));

	self->_priv->_view_mode = VIEW_MODE_MSG;
}
Beispiel #3
0
 /* return the path to the output file, or NULL in case of error */
static gboolean
convert_to_pdf (MuMsg *msg, GError **err)
{
	GString *gstr;
	const char *body;
	gchar *data;
	gboolean rv;

	gstr = g_string_sized_new (4096);

	add_header (gstr, "From", mu_msg_get_from (msg));
	add_header (gstr, "To", mu_msg_get_to (msg));
	add_header (gstr, "Cc", mu_msg_get_cc (msg));
	add_header (gstr, "Subject", mu_msg_get_subject (msg));
	add_header (gstr, "Date", mu_date_str_s
		    ("%c", mu_msg_get_date(msg)));

	gstr =	g_string_append (gstr, "<hr>\n");

	body = mu_msg_get_body_html (msg, MU_MSG_OPTION_NONE);
	if (body)
 		g_string_append_printf (gstr, "%s", body);
	else {
		body = mu_msg_get_body_text (msg, MU_MSG_OPTION_NONE);
		if (body) {
			gchar *esc;
			esc = g_markup_escape_text (body, -1);
			g_string_append_printf (gstr, "<pre>\n%s\n</pre>",
						esc);
			g_free (esc);
		} else
			gstr = g_string_append
				(gstr, "<i>No body</i>\n");
	}

	data = g_string_free (gstr, FALSE);
	rv = generate_pdf (msg, data, err);
	g_free (data);

	return rv;
}
Beispiel #4
0
static SCM
get_body (MuMsg *msg, gboolean html)
{
	SCM data;
	const char* body;
	MuMsgOptions opts;

	opts = MU_MSG_OPTION_NONE;

	if (html)
		body = mu_msg_get_body_html (msg, opts);
	else
		body = mu_msg_get_body_text (msg, opts);

	if (body)
		data = mu_guile_scm_from_str (body);
	else
		data = SCM_BOOL_F;

	/* explicitly close the file backend, so we won't run of fds */
	mu_msg_unload_msg_file (msg);

	return data;
}