Beispiel #1
0
static MuError
open_part (MuMsg *msg, unsigned docid, unsigned index, GError **err)
{
	char *targetpath;
	gboolean rv;

	targetpath = mu_msg_part_get_cache_path (msg,MU_MSG_OPTION_NONE,
						 index, err);
	if (!targetpath)
		return print_and_clear_g_error (err);

	rv = mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING,
			       targetpath, index, err);
	if (!rv) {
		print_and_clear_g_error (err);
		goto leave;
	}

	rv = mu_util_play (targetpath, TRUE,/*allow local*/
			   FALSE/*allow remote*/, err);
	if (!rv)
		print_and_clear_g_error (err);
	else {
		gchar *path;
		path = mu_str_escape_c_literal (targetpath, FALSE);
		print_expr ("(:info open :message \"%s has been opened\")",
			    path);
		g_free (path);
	}
leave:
	g_free (targetpath);
	return MU_OK;
}
Beispiel #2
0
gchar*
mu_msg_part_save_temp (MuMsg *msg, MuMsgOptions opts, guint partidx, GError **err)
{
	gchar *filepath;

	filepath = mu_msg_part_get_cache_path (msg, opts, partidx, err);
	if (!filepath)
		return NULL;

	if (!mu_msg_part_save (msg, opts, filepath, partidx, err)) {
		g_free (filepath);
		return NULL;
	}

	return filepath;
}
Beispiel #3
0
static MuError
temp_part (MuMsg *msg, unsigned docid, unsigned index, GSList *args,
	   GError **err)
{
	const char *what, *param;
	char *path;

	GET_STRING_OR_ERROR_RETURN (args, "what", &what, err);
	param = get_string_from_args (args, "param", TRUE, NULL);

	path = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE,
					   index, err);
	if (!path)
		print_and_clear_g_error (err);
	else if (!mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING,
				    path, index, err))
		print_and_clear_g_error (err);
	else {
		gchar *escpath;
		escpath = mu_str_escape_c_literal (path, FALSE);

		if (param) {
			char *escparam;
			escparam = mu_str_escape_c_literal (param, FALSE);
			print_expr ("(:temp \"%s\""
				    " :what \"%s\""
				    " :docid %u"
				    " :param \"%s\""")",
				    escpath, what, docid, escparam);
			g_free (escparam);
		} else
			print_expr ("(:temp \"%s\" :what \"%s\" :docid %u)",
				    escpath, what, docid);

		g_free (escpath);

	}

	g_free (path);
	return MU_OK;
}
Beispiel #4
0
static char*
get_temp_file (MuMsg *msg, MuMsgOptions opts, unsigned index)
{
	char *path;
	GError *err;

	err = NULL;
	path = mu_msg_part_get_cache_path (msg, opts, index, &err);
	if (!path)
		goto errexit;

	if (!mu_msg_part_save (msg, opts, path, index, &err))
		goto errexit;

	return path;

errexit:
	g_warning ("failed to save mime part: %s",
		   err->message ? err->message : "something went wrong");
	g_clear_error (&err);
	g_free (path);
	return NULL;
}
Beispiel #5
0
static char*
save_file_for_cid (MuMsg *msg, const char* cid)
{
	gint idx;
	gchar *filepath;
	GError *err;

	g_return_val_if_fail (msg, NULL);
	g_return_val_if_fail (cid, NULL);

	idx = mu_msg_find_index_for_cid (msg, MU_MSG_OPTION_NONE, cid);
	if (idx < 0) {
		g_warning ("%s: cannot find %s", __FUNCTION__, cid);
		return NULL;
	}

	err = NULL;
	filepath = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, idx, NULL);
	if (!filepath)
		goto errexit;

	if (!mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING, filepath, idx,
			       &err))
		goto errexit;

	return filepath;

errexit:
	g_warning ("%s: failed to save %s: %s", __FUNCTION__,
		   filepath,
		   err&&err->message?err->message:"error");
	g_clear_error (&err);
	g_free (filepath);

	return NULL;
}