Example #1
0
/* a summary_len of 0 mean 'don't show summary, show body */
static void
body_or_summary (MuMsg *msg, MuConfig *opts)
{
	const char *body;
	gboolean color;

	color = !opts->nocolor;
	body = mu_msg_get_body_text (msg,
				     mu_config_get_msg_options(opts) |
				     MU_MSG_OPTION_CONSOLE_PASSWORD);
	if (!body) {
		if (mu_msg_get_flags (msg) & MU_FLAG_ENCRYPTED) {
			color_maybe (MU_COLOR_CYAN);
			g_print ("[No body found; "
				 "message has encrypted parts]\n");
		} else {
			color_maybe (MU_COLOR_MAGENTA);
			g_print ("[No body found]\n");
		}
		color_maybe (MU_COLOR_DEFAULT);
		return;
	}

	if (opts->summary_len != 0) {
		gchar *summ;
		summ = mu_str_summarize (body, opts->summary_len);
		print_field ("Summary", summ, color);
		g_free (summ);
	} else {
		mu_util_print_encoded ("%s", body);
		if (!g_str_has_suffix (body, "\n"))
			g_print ("\n");
	}
}
Example #2
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));
}
Example #3
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;
}
Example #4
0
File: msg2pdf.c Project: Popsch/mu
 /* 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;
}
Example #5
0
static void
print_summary (MuMsg *msg, MuConfig *opts)
{
	const char* body;
	char *summ;
	MuMsgOptions msgopts;

	msgopts = mu_config_get_msg_options (opts);
	body = mu_msg_get_body_text(msg, msgopts);

	if (body)
		summ = mu_str_summarize (body, (unsigned)opts->summary_len);
	else
		summ = NULL;

	g_print ("Summary: ");
	mu_util_fputs_encoded (summ ? summ : "<none>", stdout);
	g_print ("\n");

	g_free (summ);
}
Example #6
0
File: mu-cmd.c Project: antono/mu
static void
body_or_summary (MuMsg *msg, gboolean summary, gboolean color)
{
	const char* field;
	const int SUMMARY_LEN = 5;

	field = mu_msg_get_body_text (msg);
	if (!field)
		return; /* no body -- nothing more to do */

	if (summary) {
		gchar *summ;
		summ = mu_str_summarize (field, SUMMARY_LEN);
		print_field ("Summary", summ, color);
		g_free (summ);
	} else {
		color_maybe (MU_COLOR_YELLOW);
		mu_util_print_encoded ("\n%s\n", field);
		color_maybe (MU_COLOR_DEFAULT);
	}
}
Example #7
0
File: mu-cmd.c Project: jleechpe/mu
/* a summary_len of 0 mean 'don't show summary, show body */
static void
body_or_summary (MuMsg *msg, MuConfig *opts)
{
	const char *body;
	gboolean color;

	color = !opts->nocolor;
	body = mu_msg_get_body_text (msg,
				     mu_config_get_msg_options(opts));
	if (!body)
		return;

	if (opts->summary_len != 0) {
		gchar *summ;
		summ = mu_str_summarize (body, opts->summary_len);
		print_field ("Summary", summ, color);
		g_free (summ);
	} else {
		color_maybe (MU_COLOR_YELLOW);
		mu_util_print_encoded ("\n%s\n", body);
		color_maybe (MU_COLOR_DEFAULT);
	}
}
Example #8
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;
}